lua_api.txt 391 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520
  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. * `author`: The author of the game. It only appears when downloaded from
  69. ContentDB.
  70. * `release`: Ignore this: Should only ever be set by ContentDB, as it is
  71. an internal ID used to track versions.
  72. * `minetest.conf`:
  73. Used to set default settings when running this game.
  74. * `settingtypes.txt`:
  75. In the same format as the one in builtin.
  76. This settingtypes.txt will be parsed by the menu and the settings will be
  77. displayed in the "Games" category in the advanced settings tab.
  78. * If the game contains a folder called `textures` the server will load it as a
  79. texturepack, overriding mod textures.
  80. Any server texturepack will override mod textures and the game texturepack.
  81. Menu images
  82. -----------
  83. Games can provide custom main menu images. They are put inside a `menu`
  84. directory inside the game directory.
  85. The images are named `$identifier.png`, where `$identifier` is one of
  86. `overlay`, `background`, `footer`, `header`.
  87. If you want to specify multiple images for one identifier, add additional
  88. images named like `$identifier.$n.png`, with an ascending number $n starting
  89. with 1, and a random image will be chosen from the provided ones.
  90. Menu music
  91. -----------
  92. Games can provide custom main menu music. They are put inside a `menu`
  93. directory inside the game directory.
  94. The music files are named `theme.ogg`.
  95. If you want to specify multiple music files for one game, add additional
  96. images named like `theme.$n.ogg`, with an ascending number $n starting
  97. with 1 (max 10), and a random music file will be chosen from the provided ones.
  98. Mods
  99. ====
  100. Mod load path
  101. -------------
  102. Paths are relative to the directories listed in the [Paths] section above.
  103. * `games/<gameid>/mods/`
  104. * `mods/`
  105. * `worlds/<worldname>/worldmods/`
  106. World-specific games
  107. --------------------
  108. It is possible to include a game in a world; in this case, no mods or
  109. games are loaded or checked from anywhere else.
  110. This is useful for e.g. adventure worlds and happens if the `<worldname>/game/`
  111. directory exists.
  112. Mods should then be placed in `<worldname>/game/mods/`.
  113. Modpacks
  114. --------
  115. Mods can be put in a subdirectory, if the parent directory, which otherwise
  116. should be a mod, contains a file named `modpack.conf`.
  117. The file is a key-value store of modpack details.
  118. * `name`: The modpack name. Allows Minetest to determine the modpack name even
  119. if the folder is wrongly named.
  120. * `description`: Description of mod to be shown in the Mods tab of the main
  121. menu.
  122. * `author`: The author of the modpack. It only appears when downloaded from
  123. ContentDB.
  124. * `release`: Ignore this: Should only ever be set by ContentDB, as it is an
  125. internal ID used to track versions.
  126. * `title`: A human-readable title to address the modpack.
  127. Note: to support 0.4.x, please also create an empty modpack.txt file.
  128. Mod directory structure
  129. -----------------------
  130. mods
  131. ├── modname
  132. │   ├── mod.conf
  133. │   ├── screenshot.png
  134. │   ├── settingtypes.txt
  135. │   ├── init.lua
  136. │   ├── models
  137. │   ├── textures
  138. │   │   ├── modname_stuff.png
  139. │   │   ├── modname_stuff_normal.png
  140. │   │   ├── modname_something_else.png
  141. │   │   ├── subfolder_foo
  142. │   │   │ ├── modname_more_stuff.png
  143. │   │   │ └── another_subfolder
  144. │   │   └── bar_subfolder
  145. │   ├── sounds
  146. │   ├── media
  147. │   ├── locale
  148. │   └── <custom data>
  149. └── another
  150. ### modname
  151. The location of this directory can be fetched by using
  152. `minetest.get_modpath(modname)`.
  153. ### mod.conf
  154. A `Settings` file that provides meta information about the mod.
  155. * `name`: The mod name. Allows Minetest to determine the mod name even if the
  156. folder is wrongly named.
  157. * `description`: Description of mod to be shown in the Mods tab of the main
  158. menu.
  159. * `depends`: A comma separated list of dependencies. These are mods that must be
  160. loaded before this mod.
  161. * `optional_depends`: A comma separated list of optional dependencies.
  162. Like a dependency, but no error if the mod doesn't exist.
  163. * `author`: The author of the mod. It only appears when downloaded from
  164. ContentDB.
  165. * `release`: Ignore this: Should only ever be set by ContentDB, as it is an
  166. internal ID used to track versions.
  167. * `title`: A human-readable title to address the mod.
  168. ### `screenshot.png`
  169. A screenshot shown in the mod manager within the main menu. It should
  170. have an aspect ratio of 3:2 and a minimum size of 300×200 pixels.
  171. ### `depends.txt`
  172. **Deprecated:** you should use mod.conf instead.
  173. This file is used if there are no dependencies in mod.conf.
  174. List of mods that have to be loaded before loading this mod.
  175. A single line contains a single modname.
  176. Optional dependencies can be defined by appending a question mark
  177. to a single modname. This means that if the specified mod
  178. is missing, it does not prevent this mod from being loaded.
  179. ### `description.txt`
  180. **Deprecated:** you should use mod.conf instead.
  181. This file is used if there is no description in mod.conf.
  182. A file containing a description to be shown in the Mods tab of the main menu.
  183. ### `settingtypes.txt`
  184. The format is documented in `builtin/settingtypes.txt`.
  185. It is parsed by the main menu settings dialogue to list mod-specific
  186. settings in the "Mods" category.
  187. ### `init.lua`
  188. The main Lua script. Running this script should register everything it
  189. wants to register. Subsequent execution depends on minetest calling the
  190. registered callbacks.
  191. `minetest.settings` can be used to read custom or existing settings at load
  192. time, if necessary. (See [`Settings`])
  193. ### `textures`, `sounds`, `media`, `models`, `locale`
  194. Media files (textures, sounds, whatever) that will be transferred to the
  195. client and will be available for use by the mod and translation files for
  196. the clients (see [Translations]).
  197. It is suggested to use the folders for the purpose they are thought for,
  198. eg. put textures into `textures`, translation files into `locale`,
  199. models for entities or meshnodes into `models` et cetera.
  200. These folders and subfolders can contain subfolders.
  201. Subfolders with names starting with `_` or `.` are ignored.
  202. If a subfolder contains a media file with the same name as a media file
  203. in one of its parents, the parent's file is used.
  204. Although it is discouraged, a mod can overwrite a media file of any mod that it
  205. depends on by supplying a file with an equal name.
  206. Naming conventions
  207. ------------------
  208. Registered names should generally be in this format:
  209. modname:<whatever>
  210. `<whatever>` can have these characters:
  211. a-zA-Z0-9_
  212. This is to prevent conflicting names from corrupting maps and is
  213. enforced by the mod loader.
  214. Registered names can be overridden by prefixing the name with `:`. This can
  215. be used for overriding the registrations of some other mod.
  216. The `:` prefix can also be used for maintaining backwards compatibility.
  217. ### Example
  218. In the mod `experimental`, there is the ideal item/node/entity name `tnt`.
  219. So the name should be `experimental:tnt`.
  220. Any mod can redefine `experimental:tnt` by using the name
  221. :experimental:tnt
  222. when registering it. For this to work correctly, that mod must have
  223. `experimental` as a dependency.
  224. Aliases
  225. =======
  226. Aliases of itemnames can be added by using
  227. `minetest.register_alias(alias, original_name)` or
  228. `minetest.register_alias_force(alias, original_name)`.
  229. This adds an alias `alias` for the item called `original_name`.
  230. From now on, you can use `alias` to refer to the item `original_name`.
  231. The only difference between `minetest.register_alias` and
  232. `minetest.register_alias_force` is that if an item named `alias` already exists,
  233. `minetest.register_alias` will do nothing while
  234. `minetest.register_alias_force` will unregister it.
  235. This can be used for maintaining backwards compatibility.
  236. This can also set quick access names for things, e.g. if
  237. you have an item called `epiclylongmodname:stuff`, you could do
  238. minetest.register_alias("stuff", "epiclylongmodname:stuff")
  239. and be able to use `/giveme stuff`.
  240. Mapgen aliases
  241. --------------
  242. In a game, a certain number of these must be set to tell core mapgens which
  243. of the game's nodes are to be used for core mapgen generation. For example:
  244. minetest.register_alias("mapgen_stone", "default:stone")
  245. ### Aliases for non-V6 mapgens
  246. #### Essential aliases
  247. * `mapgen_stone`
  248. * `mapgen_water_source`
  249. * `mapgen_river_water_source`
  250. `mapgen_river_water_source` is required for mapgens with sloping rivers where
  251. it is necessary to have a river liquid node with a short `liquid_range` and
  252. `liquid_renewable = false` to avoid flooding.
  253. #### Optional aliases
  254. * `mapgen_lava_source`
  255. Fallback lava node used if cave liquids are not defined in biome definitions.
  256. Deprecated, define cave liquids in biome definitions instead.
  257. * `mapgen_cobble`
  258. Fallback node used if dungeon nodes are not defined in biome definitions.
  259. Deprecated, define dungeon nodes in biome definitions instead.
  260. ### Aliases for Mapgen V6
  261. #### Essential
  262. * `mapgen_stone`
  263. * `mapgen_water_source`
  264. * `mapgen_lava_source`
  265. * `mapgen_dirt`
  266. * `mapgen_dirt_with_grass`
  267. * `mapgen_sand`
  268. * `mapgen_tree`
  269. * `mapgen_leaves`
  270. * `mapgen_apple`
  271. * `mapgen_cobble`
  272. #### Optional
  273. * `mapgen_gravel` (falls back to stone)
  274. * `mapgen_desert_stone` (falls back to stone)
  275. * `mapgen_desert_sand` (falls back to sand)
  276. * `mapgen_dirt_with_snow` (falls back to dirt_with_grass)
  277. * `mapgen_snowblock` (falls back to dirt_with_grass)
  278. * `mapgen_snow` (not placed if missing)
  279. * `mapgen_ice` (falls back to water_source)
  280. * `mapgen_jungletree` (falls back to tree)
  281. * `mapgen_jungleleaves` (falls back to leaves)
  282. * `mapgen_junglegrass` (not placed if missing)
  283. * `mapgen_pine_tree` (falls back to tree)
  284. * `mapgen_pine_needles` (falls back to leaves)
  285. * `mapgen_stair_cobble` (falls back to cobble)
  286. * `mapgen_mossycobble` (falls back to cobble)
  287. * `mapgen_stair_desert_stone` (falls backto desert_stone)
  288. ### Setting the node used in Mapgen Singlenode
  289. By default the world is filled with air nodes. To set a different node use e.g.:
  290. minetest.register_alias("mapgen_singlenode", "default:stone")
  291. Textures
  292. ========
  293. Mods should generally prefix their textures with `modname_`, e.g. given
  294. the mod name `foomod`, a texture could be called:
  295. foomod_foothing.png
  296. Textures are referred to by their complete name, or alternatively by
  297. stripping out the file extension:
  298. * e.g. `foomod_foothing.png`
  299. * e.g. `foomod_foothing`
  300. Supported texture formats are PNG (`.png`), JPEG (`.jpg`), Bitmap (`.bmp`)
  301. and Targa (`.tga`).
  302. Since better alternatives exist, the latter two may be removed in the future.
  303. Texture modifiers
  304. -----------------
  305. There are various texture modifiers that can be used
  306. to let the client generate textures on-the-fly.
  307. The modifiers are applied directly in sRGB colorspace,
  308. i.e. without gamma-correction.
  309. ### Texture overlaying
  310. Textures can be overlaid by putting a `^` between them.
  311. Example:
  312. default_dirt.png^default_grass_side.png
  313. `default_grass_side.png` is overlaid over `default_dirt.png`.
  314. The texture with the lower resolution will be automatically upscaled to
  315. the higher resolution texture.
  316. ### Texture grouping
  317. Textures can be grouped together by enclosing them in `(` and `)`.
  318. Example: `cobble.png^(thing1.png^thing2.png)`
  319. A texture for `thing1.png^thing2.png` is created and the resulting
  320. texture is overlaid on top of `cobble.png`.
  321. ### Escaping
  322. Modifiers that accept texture names (e.g. `[combine`) accept escaping to allow
  323. passing complex texture names as arguments. Escaping is done with backslash and
  324. is required for `^` and `:`.
  325. Example: `cobble.png^[lowpart:50:color.png\^[mask\:trans.png`
  326. The lower 50 percent of `color.png^[mask:trans.png` are overlaid
  327. on top of `cobble.png`.
  328. ### Advanced texture modifiers
  329. #### Crack
  330. * `[crack:<n>:<p>`
  331. * `[cracko:<n>:<p>`
  332. * `[crack:<t>:<n>:<p>`
  333. * `[cracko:<t>:<n>:<p>`
  334. Parameters:
  335. * `<t>`: tile count (in each direction)
  336. * `<n>`: animation frame count
  337. * `<p>`: current animation frame
  338. Draw a step of the crack animation on the texture.
  339. `crack` draws it normally, while `cracko` lays it over, keeping transparent
  340. pixels intact.
  341. Example:
  342. default_cobble.png^[crack:10:1
  343. #### `[combine:<w>x<h>:<x1>,<y1>=<file1>:<x2>,<y2>=<file2>:...`
  344. * `<w>`: width
  345. * `<h>`: height
  346. * `<x>`: x position
  347. * `<y>`: y position
  348. * `<file>`: texture to combine
  349. Creates a texture of size `<w>` times `<h>` and blits the listed files to their
  350. specified coordinates.
  351. Example:
  352. [combine:16x32:0,0=default_cobble.png:0,16=default_wood.png
  353. #### `[resize:<w>x<h>`
  354. Resizes the texture to the given dimensions.
  355. Example:
  356. default_sandstone.png^[resize:16x16
  357. #### `[opacity:<r>`
  358. Makes the base image transparent according to the given ratio.
  359. `r` must be between 0 (transparent) and 255 (opaque).
  360. Example:
  361. default_sandstone.png^[opacity:127
  362. #### `[invert:<mode>`
  363. Inverts the given channels of the base image.
  364. Mode may contain the characters "r", "g", "b", "a".
  365. Only the channels that are mentioned in the mode string will be inverted.
  366. Example:
  367. default_apple.png^[invert:rgb
  368. #### `[brighten`
  369. Brightens the texture.
  370. Example:
  371. tnt_tnt_side.png^[brighten
  372. #### `[noalpha`
  373. Makes the texture completely opaque.
  374. Example:
  375. default_leaves.png^[noalpha
  376. #### `[makealpha:<r>,<g>,<b>`
  377. Convert one color to transparency.
  378. Example:
  379. default_cobble.png^[makealpha:128,128,128
  380. #### `[transform<t>`
  381. * `<t>`: transformation(s) to apply
  382. Rotates and/or flips the image.
  383. `<t>` can be a number (between 0 and 7) or a transform name.
  384. Rotations are counter-clockwise.
  385. 0 I identity
  386. 1 R90 rotate by 90 degrees
  387. 2 R180 rotate by 180 degrees
  388. 3 R270 rotate by 270 degrees
  389. 4 FX flip X
  390. 5 FXR90 flip X then rotate by 90 degrees
  391. 6 FY flip Y
  392. 7 FYR90 flip Y then rotate by 90 degrees
  393. Example:
  394. default_stone.png^[transformFXR90
  395. #### `[inventorycube{<top>{<left>{<right>`
  396. Escaping does not apply here and `^` is replaced by `&` in texture names
  397. instead.
  398. Create an inventory cube texture using the side textures.
  399. Example:
  400. [inventorycube{grass.png{dirt.png&grass_side.png{dirt.png&grass_side.png
  401. Creates an inventorycube with `grass.png`, `dirt.png^grass_side.png` and
  402. `dirt.png^grass_side.png` textures
  403. #### `[lowpart:<percent>:<file>`
  404. Blit the lower `<percent>`% part of `<file>` on the texture.
  405. Example:
  406. base.png^[lowpart:25:overlay.png
  407. #### `[verticalframe:<t>:<n>`
  408. * `<t>`: animation frame count
  409. * `<n>`: current animation frame
  410. Crops the texture to a frame of a vertical animation.
  411. Example:
  412. default_torch_animated.png^[verticalframe:16:8
  413. #### `[mask:<file>`
  414. Apply a mask to the base image.
  415. The mask is applied using binary AND.
  416. #### `[sheet:<w>x<h>:<x>,<y>`
  417. Retrieves a tile at position x,y from the base image
  418. which it assumes to be a tilesheet with dimensions w,h.
  419. #### `[colorize:<color>:<ratio>`
  420. Colorize the textures with the given color.
  421. `<color>` is specified as a `ColorString`.
  422. `<ratio>` is an int ranging from 0 to 255 or the word "`alpha`". If
  423. it is an int, then it specifies how far to interpolate between the
  424. colors where 0 is only the texture color and 255 is only `<color>`. If
  425. omitted, the alpha of `<color>` will be used as the ratio. If it is
  426. the word "`alpha`", then each texture pixel will contain the RGB of
  427. `<color>` and the alpha of `<color>` multiplied by the alpha of the
  428. texture pixel.
  429. #### `[multiply:<color>`
  430. Multiplies texture colors with the given color.
  431. `<color>` is specified as a `ColorString`.
  432. Result is more like what you'd expect if you put a color on top of another
  433. color, meaning white surfaces get a lot of your new color while black parts
  434. don't change very much.
  435. #### `[png:<base64>`
  436. Embed a base64 encoded PNG image in the texture string.
  437. You can produce a valid string for this by calling
  438. `minetest.encode_base64(minetest.encode_png(tex))`,
  439. refer to the documentation of these functions for details.
  440. You can use this to send disposable images such as captchas
  441. to individual clients, or render things that would be too
  442. expensive to compose with `[combine:`.
  443. IMPORTANT: Avoid sending large images this way.
  444. This is not a replacement for asset files, do not use it to do anything
  445. that you could instead achieve by just using a file.
  446. In particular consider `minetest.dynamic_add_media` and test whether
  447. using other texture modifiers could result in a shorter string than
  448. embedding a whole image, this may vary by use case.
  449. Hardware coloring
  450. -----------------
  451. The goal of hardware coloring is to simplify the creation of
  452. colorful nodes. If your textures use the same pattern, and they only
  453. differ in their color (like colored wool blocks), you can use hardware
  454. coloring instead of creating and managing many texture files.
  455. All of these methods use color multiplication (so a white-black texture
  456. with red coloring will result in red-black color).
  457. ### Static coloring
  458. This method is useful if you wish to create nodes/items with
  459. the same texture, in different colors, each in a new node/item definition.
  460. #### Global color
  461. When you register an item or node, set its `color` field (which accepts a
  462. `ColorSpec`) to the desired color.
  463. An `ItemStack`'s static color can be overwritten by the `color` metadata
  464. field. If you set that field to a `ColorString`, that color will be used.
  465. #### Tile color
  466. Each tile may have an individual static color, which overwrites every
  467. other coloring method. To disable the coloring of a face,
  468. set its color to white (because multiplying with white does nothing).
  469. You can set the `color` property of the tiles in the node's definition
  470. if the tile is in table format.
  471. ### Palettes
  472. For nodes and items which can have many colors, a palette is more
  473. suitable. A palette is a texture, which can contain up to 256 pixels.
  474. Each pixel is one possible color for the node/item.
  475. You can register one node/item, which can have up to 256 colors.
  476. #### Palette indexing
  477. When using palettes, you always provide a pixel index for the given
  478. node or `ItemStack`. The palette is read from left to right and from
  479. top to bottom. If the palette has less than 256 pixels, then it is
  480. stretched to contain exactly 256 pixels (after arranging the pixels
  481. to one line). The indexing starts from 0.
  482. Examples:
  483. * 16x16 palette, index = 0: the top left corner
  484. * 16x16 palette, index = 4: the fifth pixel in the first row
  485. * 16x16 palette, index = 16: the pixel below the top left corner
  486. * 16x16 palette, index = 255: the bottom right corner
  487. * 2 (width) x 4 (height) palette, index = 31: the top left corner.
  488. The palette has 8 pixels, so each pixel is stretched to 32 pixels,
  489. to ensure the total 256 pixels.
  490. * 2x4 palette, index = 32: the top right corner
  491. * 2x4 palette, index = 63: the top right corner
  492. * 2x4 palette, index = 64: the pixel below the top left corner
  493. #### Using palettes with items
  494. When registering an item, set the item definition's `palette` field to
  495. a texture. You can also use texture modifiers.
  496. The `ItemStack`'s color depends on the `palette_index` field of the
  497. stack's metadata. `palette_index` is an integer, which specifies the
  498. index of the pixel to use.
  499. #### Linking palettes with nodes
  500. When registering a node, set the item definition's `palette` field to
  501. a texture. You can also use texture modifiers.
  502. The node's color depends on its `param2`, so you also must set an
  503. appropriate `paramtype2`:
  504. * `paramtype2 = "color"` for nodes which use their full `param2` for
  505. palette indexing. These nodes can have 256 different colors.
  506. The palette should contain 256 pixels.
  507. * `paramtype2 = "colorwallmounted"` for nodes which use the first
  508. five bits (most significant) of `param2` for palette indexing.
  509. The remaining three bits are describing rotation, as in `wallmounted`
  510. paramtype2. Division by 8 yields the palette index (without stretching the
  511. palette). These nodes can have 32 different colors, and the palette
  512. should contain 32 pixels.
  513. Examples:
  514. * `param2 = 17` is 2 * 8 + 1, so the rotation is 1 and the third (= 2 + 1)
  515. pixel will be picked from the palette.
  516. * `param2 = 35` is 4 * 8 + 3, so the rotation is 3 and the fifth (= 4 + 1)
  517. pixel will be picked from the palette.
  518. * `paramtype2 = "colorfacedir"` for nodes which use the first
  519. three bits of `param2` for palette indexing. The remaining
  520. five bits are describing rotation, as in `facedir` paramtype2.
  521. Division by 32 yields the palette index (without stretching the
  522. palette). These nodes can have 8 different colors, and the
  523. palette should contain 8 pixels.
  524. Examples:
  525. * `param2 = 17` is 0 * 32 + 17, so the rotation is 17 and the
  526. first (= 0 + 1) pixel will be picked from the palette.
  527. * `param2 = 35` is 1 * 32 + 3, so the rotation is 3 and the
  528. second (= 1 + 1) pixel will be picked from the palette.
  529. To colorize a node on the map, set its `param2` value (according
  530. to the node's paramtype2).
  531. ### Conversion between nodes in the inventory and on the map
  532. Static coloring is the same for both cases, there is no need
  533. for conversion.
  534. If the `ItemStack`'s metadata contains the `color` field, it will be
  535. lost on placement, because nodes on the map can only use palettes.
  536. If the `ItemStack`'s metadata contains the `palette_index` field, it is
  537. automatically transferred between node and item forms by the engine,
  538. when a player digs or places a colored node.
  539. You can disable this feature by setting the `drop` field of the node
  540. to itself (without metadata).
  541. To transfer the color to a special drop, you need a drop table.
  542. Example:
  543. minetest.register_node("mod:stone", {
  544. description = "Stone",
  545. tiles = {"default_stone.png"},
  546. paramtype2 = "color",
  547. palette = "palette.png",
  548. drop = {
  549. items = {
  550. -- assume that mod:cobblestone also has the same palette
  551. {items = {"mod:cobblestone"}, inherit_color = true },
  552. }
  553. }
  554. })
  555. ### Colored items in craft recipes
  556. Craft recipes only support item strings, but fortunately item strings
  557. can also contain metadata. Example craft recipe registration:
  558. minetest.register_craft({
  559. output = minetest.itemstring_with_palette("wool:block", 3),
  560. type = "shapeless",
  561. recipe = {
  562. "wool:block",
  563. "dye:red",
  564. },
  565. })
  566. To set the `color` field, you can use `minetest.itemstring_with_color`.
  567. Metadata field filtering in the `recipe` field are not supported yet,
  568. so the craft output is independent of the color of the ingredients.
  569. Soft texture overlay
  570. --------------------
  571. Sometimes hardware coloring is not enough, because it affects the
  572. whole tile. Soft texture overlays were added to Minetest to allow
  573. the dynamic coloring of only specific parts of the node's texture.
  574. For example a grass block may have colored grass, while keeping the
  575. dirt brown.
  576. These overlays are 'soft', because unlike texture modifiers, the layers
  577. are not merged in the memory, but they are simply drawn on top of each
  578. other. This allows different hardware coloring, but also means that
  579. tiles with overlays are drawn slower. Using too much overlays might
  580. cause FPS loss.
  581. For inventory and wield images you can specify overlays which
  582. hardware coloring does not modify. You have to set `inventory_overlay`
  583. and `wield_overlay` fields to an image name.
  584. To define a node overlay, simply set the `overlay_tiles` field of the node
  585. definition. These tiles are defined in the same way as plain tiles:
  586. they can have a texture name, color etc.
  587. To skip one face, set that overlay tile to an empty string.
  588. Example (colored grass block):
  589. minetest.register_node("default:dirt_with_grass", {
  590. description = "Dirt with Grass",
  591. -- Regular tiles, as usual
  592. -- The dirt tile disables palette coloring
  593. tiles = {{name = "default_grass.png"},
  594. {name = "default_dirt.png", color = "white"}},
  595. -- Overlay tiles: define them in the same style
  596. -- The top and bottom tile does not have overlay
  597. overlay_tiles = {"", "",
  598. {name = "default_grass_side.png"}},
  599. -- Global color, used in inventory
  600. color = "green",
  601. -- Palette in the world
  602. paramtype2 = "color",
  603. palette = "default_foilage.png",
  604. })
  605. Sounds
  606. ======
  607. Only Ogg Vorbis files are supported.
  608. For positional playing of sounds, only single-channel (mono) files are
  609. supported. Otherwise OpenAL will play them non-positionally.
  610. Mods should generally prefix their sounds with `modname_`, e.g. given
  611. the mod name "`foomod`", a sound could be called:
  612. foomod_foosound.ogg
  613. Sounds are referred to by their name with a dot, a single digit and the
  614. file extension stripped out. When a sound is played, the actual sound file
  615. is chosen randomly from the matching sounds.
  616. When playing the sound `foomod_foosound`, the sound is chosen randomly
  617. from the available ones of the following files:
  618. * `foomod_foosound.ogg`
  619. * `foomod_foosound.0.ogg`
  620. * `foomod_foosound.1.ogg`
  621. * (...)
  622. * `foomod_foosound.9.ogg`
  623. Examples of sound parameter tables:
  624. -- Play locationless on all clients
  625. {
  626. gain = 1.0, -- default
  627. fade = 0.0, -- default, change to a value > 0 to fade the sound in
  628. pitch = 1.0, -- default
  629. }
  630. -- Play locationless to one player
  631. {
  632. to_player = name,
  633. gain = 1.0, -- default
  634. fade = 0.0, -- default, change to a value > 0 to fade the sound in
  635. pitch = 1.0, -- default
  636. }
  637. -- Play locationless to one player, looped
  638. {
  639. to_player = name,
  640. gain = 1.0, -- default
  641. loop = true,
  642. }
  643. -- Play at a location
  644. {
  645. pos = {x = 1, y = 2, z = 3},
  646. gain = 1.0, -- default
  647. max_hear_distance = 32, -- default, uses an euclidean metric
  648. }
  649. -- Play connected to an object, looped
  650. {
  651. object = <an ObjectRef>,
  652. gain = 1.0, -- default
  653. max_hear_distance = 32, -- default, uses an euclidean metric
  654. loop = true,
  655. }
  656. -- Play at a location, heard by anyone *but* the given player
  657. {
  658. pos = {x = 32, y = 0, z = 100},
  659. max_hear_distance = 40,
  660. exclude_player = name,
  661. }
  662. Looped sounds must either be connected to an object or played locationless to
  663. one player using `to_player = name`.
  664. A positional sound will only be heard by players that are within
  665. `max_hear_distance` of the sound position, at the start of the sound.
  666. `exclude_player = name` can be applied to locationless, positional and object-
  667. bound sounds to exclude a single player from hearing them.
  668. `SimpleSoundSpec`
  669. -----------------
  670. Specifies a sound name, gain (=volume) and pitch.
  671. This is either a string or a table.
  672. In string form, you just specify the sound name or
  673. the empty string for no sound.
  674. Table form has the following fields:
  675. * `name`: Sound name
  676. * `gain`: Volume (`1.0` = 100%)
  677. * `pitch`: Pitch (`1.0` = 100%)
  678. `gain` and `pitch` are optional and default to `1.0`.
  679. Examples:
  680. * `""`: No sound
  681. * `{}`: No sound
  682. * `"default_place_node"`: Play e.g. `default_place_node.ogg`
  683. * `{name = "default_place_node"}`: Same as above
  684. * `{name = "default_place_node", gain = 0.5}`: 50% volume
  685. * `{name = "default_place_node", gain = 0.9, pitch = 1.1}`: 90% volume, 110% pitch
  686. Special sound files
  687. -------------------
  688. These sound files are played back by the engine if provided.
  689. * `player_damage`: Played when the local player takes damage (gain = 0.5)
  690. * `player_falling_damage`: Played when the local player takes
  691. damage by falling (gain = 0.5)
  692. * `player_jump`: Played when the local player jumps
  693. * `default_dig_<groupname>`: Default node digging sound
  694. (see node sound definition for details)
  695. Registered definitions
  696. ======================
  697. Anything added using certain [Registration functions] gets added to one or more
  698. of the global [Registered definition tables].
  699. Note that in some cases you will stumble upon things that are not contained
  700. in these tables (e.g. when a mod has been removed). Always check for
  701. existence before trying to access the fields.
  702. Example:
  703. All nodes register with `minetest.register_node` get added to the table
  704. `minetest.registered_nodes`.
  705. If you want to check the drawtype of a node, you could do it like this:
  706. local def = minetest.registered_nodes[nodename]
  707. local drawtype = def and def.drawtype
  708. Nodes
  709. =====
  710. Nodes are the bulk data of the world: cubes and other things that take the
  711. space of a cube. Huge amounts of them are handled efficiently, but they
  712. are quite static.
  713. The definition of a node is stored and can be accessed by using
  714. minetest.registered_nodes[node.name]
  715. See [Registered definitions].
  716. Nodes are passed by value between Lua and the engine.
  717. They are represented by a table:
  718. {name="name", param1=num, param2=num}
  719. `param1` and `param2` are 8-bit integers ranging from 0 to 255. The engine uses
  720. them for certain automated functions. If you don't use these functions, you can
  721. use them to store arbitrary values.
  722. Node paramtypes
  723. ---------------
  724. The functions of `param1` and `param2` are determined by certain fields in the
  725. node definition.
  726. The function of `param1` is determined by `paramtype` in node definition.
  727. `param1` is reserved for the engine when `paramtype != "none"`.
  728. * `paramtype = "light"`
  729. * The value stores light with and without sun in its lower and upper 4 bits
  730. respectively.
  731. * Required by a light source node to enable spreading its light.
  732. * Required by the following drawtypes as they determine their visual
  733. brightness from their internal light value:
  734. * torchlike
  735. * signlike
  736. * firelike
  737. * fencelike
  738. * raillike
  739. * nodebox
  740. * mesh
  741. * plantlike
  742. * plantlike_rooted
  743. * `paramtype = "none"`
  744. * `param1` will not be used by the engine and can be used to store
  745. an arbitrary value
  746. The function of `param2` is determined by `paramtype2` in node definition.
  747. `param2` is reserved for the engine when `paramtype2 != "none"`.
  748. * `paramtype2 = "flowingliquid"`
  749. * Used by `drawtype = "flowingliquid"` and `liquidtype = "flowing"`
  750. * The liquid level and a flag of the liquid are stored in `param2`
  751. * Bits 0-2: Liquid level (0-7). The higher, the more liquid is in this node;
  752. see `minetest.get_node_level`, `minetest.set_node_level` and `minetest.add_node_level`
  753. to access/manipulate the content of this field
  754. * Bit 3: If set, liquid is flowing downwards (no graphical effect)
  755. * `paramtype2 = "wallmounted"`
  756. * Supported drawtypes: "torchlike", "signlike", "plantlike",
  757. "plantlike_rooted", "normal", "nodebox", "mesh"
  758. * The rotation of the node is stored in `param2`
  759. * You can make this value by using `minetest.dir_to_wallmounted()`
  760. * Values range 0 - 5
  761. * The value denotes at which direction the node is "mounted":
  762. 0 = y+, 1 = y-, 2 = x+, 3 = x-, 4 = z+, 5 = z-
  763. * `paramtype2 = "facedir"`
  764. * Supported drawtypes: "normal", "nodebox", "mesh"
  765. * The rotation of the node is stored in `param2`. Furnaces and chests are
  766. rotated this way. Can be made by using `minetest.dir_to_facedir()`.
  767. * Values range 0 - 23
  768. * facedir / 4 = axis direction:
  769. 0 = y+, 1 = z+, 2 = z-, 3 = x+, 4 = x-, 5 = y-
  770. * facedir modulo 4 = rotation around that axis
  771. * `paramtype2 = "leveled"`
  772. * Only valid for "nodebox" with 'type = "leveled"', and "plantlike_rooted".
  773. * Leveled nodebox:
  774. * The level of the top face of the nodebox is stored in `param2`.
  775. * The other faces are defined by 'fixed = {}' like 'type = "fixed"'
  776. nodeboxes.
  777. * The nodebox height is (`param2` / 64) nodes.
  778. * The maximum accepted value of `param2` is 127.
  779. * Rooted plantlike:
  780. * The height of the 'plantlike' section is stored in `param2`.
  781. * The height is (`param2` / 16) nodes.
  782. * `paramtype2 = "degrotate"`
  783. * Valid for `plantlike` and `mesh` drawtypes. The rotation of the node is
  784. stored in `param2`.
  785. * Values range 0–239. The value stored in `param2` is multiplied by 1.5 to
  786. get the actual rotation in degrees of the node.
  787. * `paramtype2 = "meshoptions"`
  788. * Only valid for "plantlike" drawtype. `param2` encodes the shape and
  789. optional modifiers of the "plant". `param2` is a bitfield.
  790. * Bits 0 to 2 select the shape.
  791. Use only one of the values below:
  792. * 0 = a "x" shaped plant (ordinary plant)
  793. * 1 = a "+" shaped plant (just rotated 45 degrees)
  794. * 2 = a "*" shaped plant with 3 faces instead of 2
  795. * 3 = a "#" shaped plant with 4 faces instead of 2
  796. * 4 = a "#" shaped plant with 4 faces that lean outwards
  797. * 5-7 are unused and reserved for future meshes.
  798. * Bits 3 to 7 are used to enable any number of optional modifiers.
  799. Just add the corresponding value(s) below to `param2`:
  800. * 8 - Makes the plant slightly vary placement horizontally
  801. * 16 - Makes the plant mesh 1.4x larger
  802. * 32 - Moves each face randomly a small bit down (1/8 max)
  803. * values 64 and 128 (bits 6-7) are reserved for future use.
  804. * Example: `param2 = 0` selects a normal "x" shaped plant
  805. * Example: `param2 = 17` selects a "+" shaped plant, 1.4x larger (1+16)
  806. * `paramtype2 = "color"`
  807. * `param2` tells which color is picked from the palette.
  808. The palette should have 256 pixels.
  809. * `paramtype2 = "colorfacedir"`
  810. * Same as `facedir`, but with colors.
  811. * The first three bits of `param2` tells which color is picked from the
  812. palette. The palette should have 8 pixels.
  813. * `paramtype2 = "colorwallmounted"`
  814. * Same as `wallmounted`, but with colors.
  815. * The first five bits of `param2` tells which color is picked from the
  816. palette. The palette should have 32 pixels.
  817. * `paramtype2 = "glasslikeliquidlevel"`
  818. * Only valid for "glasslike_framed" or "glasslike_framed_optional"
  819. drawtypes. "glasslike_framed_optional" nodes are only affected if the
  820. "Connected Glass" setting is enabled.
  821. * Bits 0-5 define 64 levels of internal liquid, 0 being empty and 63 being
  822. full.
  823. * Bits 6 and 7 modify the appearance of the frame and node faces. One or
  824. both of these values may be added to `param2`:
  825. * 64 - Makes the node not connect with neighbors above or below it.
  826. * 128 - Makes the node not connect with neighbors to its sides.
  827. * Liquid texture is defined using `special_tiles = {"modname_tilename.png"}`
  828. * `paramtype2 = "colordegrotate"`
  829. * Same as `degrotate`, but with colors.
  830. * The first (most-significant) three bits of `param2` tells which color
  831. is picked from the palette. The palette should have 8 pixels.
  832. * Remaining 5 bits store rotation in range 0–23 (i.e. in 15° steps)
  833. * `paramtype2 = "none"`
  834. * `param2` will not be used by the engine and can be used to store
  835. an arbitrary value
  836. Nodes can also contain extra data. See [Node Metadata].
  837. Node drawtypes
  838. --------------
  839. There are a bunch of different looking node types.
  840. Look for examples in `games/devtest` or `games/minetest_game`.
  841. * `normal`
  842. * A node-sized cube.
  843. * `airlike`
  844. * Invisible, uses no texture.
  845. * `liquid`
  846. * The cubic source node for a liquid.
  847. * Faces bordering to the same node are never rendered.
  848. * Connects to node specified in `liquid_alternative_flowing`.
  849. * Use `backface_culling = false` for the tiles you want to make
  850. visible when inside the node.
  851. * `flowingliquid`
  852. * The flowing version of a liquid, appears with various heights and slopes.
  853. * Faces bordering to the same node are never rendered.
  854. * Connects to node specified in `liquid_alternative_source`.
  855. * Node textures are defined with `special_tiles` where the first tile
  856. is for the top and bottom faces and the second tile is for the side
  857. faces.
  858. * `tiles` is used for the item/inventory/wield image rendering.
  859. * Use `backface_culling = false` for the special tiles you want to make
  860. visible when inside the node
  861. * `glasslike`
  862. * Often used for partially-transparent nodes.
  863. * Only external sides of textures are visible.
  864. * `glasslike_framed`
  865. * All face-connected nodes are drawn as one volume within a surrounding
  866. frame.
  867. * The frame appearance is generated from the edges of the first texture
  868. specified in `tiles`. The width of the edges used are 1/16th of texture
  869. size: 1 pixel for 16x16, 2 pixels for 32x32 etc.
  870. * The glass 'shine' (or other desired detail) on each node face is supplied
  871. by the second texture specified in `tiles`.
  872. * `glasslike_framed_optional`
  873. * This switches between the above 2 drawtypes according to the menu setting
  874. 'Connected Glass'.
  875. * `allfaces`
  876. * Often used for partially-transparent nodes.
  877. * External and internal sides of textures are visible.
  878. * `allfaces_optional`
  879. * Often used for leaves nodes.
  880. * This switches between `normal`, `glasslike` and `allfaces` according to
  881. the menu setting: Opaque Leaves / Simple Leaves / Fancy Leaves.
  882. * With 'Simple Leaves' selected, the texture specified in `special_tiles`
  883. is used instead, if present. This allows a visually thicker texture to be
  884. used to compensate for how `glasslike` reduces visual thickness.
  885. * `torchlike`
  886. * A single vertical texture.
  887. * If `paramtype2="[color]wallmounted"`:
  888. * If placed on top of a node, uses the first texture specified in `tiles`.
  889. * If placed against the underside of a node, uses the second texture
  890. specified in `tiles`.
  891. * If placed on the side of a node, uses the third texture specified in
  892. `tiles` and is perpendicular to that node.
  893. * If `paramtype2="none"`:
  894. * Will be rendered as if placed on top of a node (see
  895. above) and only the first texture is used.
  896. * `signlike`
  897. * A single texture parallel to, and mounted against, the top, underside or
  898. side of a node.
  899. * If `paramtype2="[color]wallmounted"`, it rotates according to `param2`
  900. * If `paramtype2="none"`, it will always be on the floor.
  901. * `plantlike`
  902. * Two vertical and diagonal textures at right-angles to each other.
  903. * See `paramtype2 = "meshoptions"` above for other options.
  904. * `firelike`
  905. * When above a flat surface, appears as 6 textures, the central 2 as
  906. `plantlike` plus 4 more surrounding those.
  907. * If not above a surface the central 2 do not appear, but the texture
  908. appears against the faces of surrounding nodes if they are present.
  909. * `fencelike`
  910. * A 3D model suitable for a wooden fence.
  911. * One placed node appears as a single vertical post.
  912. * Adjacently-placed nodes cause horizontal bars to appear between them.
  913. * `raillike`
  914. * Often used for tracks for mining carts.
  915. * Requires 4 textures to be specified in `tiles`, in order: Straight,
  916. curved, t-junction, crossing.
  917. * Each placed node automatically switches to a suitable rotated texture
  918. determined by the adjacent `raillike` nodes, in order to create a
  919. continuous track network.
  920. * Becomes a sloping node if placed against stepped nodes.
  921. * `nodebox`
  922. * Often used for stairs and slabs.
  923. * Allows defining nodes consisting of an arbitrary number of boxes.
  924. * See [Node boxes] below for more information.
  925. * `mesh`
  926. * Uses models for nodes.
  927. * Tiles should hold model materials textures.
  928. * Only static meshes are implemented.
  929. * For supported model formats see Irrlicht engine documentation.
  930. * `plantlike_rooted`
  931. * Enables underwater `plantlike` without air bubbles around the nodes.
  932. * Consists of a base cube at the co-ordinates of the node plus a
  933. `plantlike` extension above
  934. * If `paramtype2="leveled", the `plantlike` extension has a height
  935. of `param2 / 16` nodes, otherwise it's the height of 1 node
  936. * If `paramtype2="wallmounted"`, the `plantlike` extension
  937. will be at one of the corresponding 6 sides of the base cube.
  938. Also, the base cube rotates like a `normal` cube would
  939. * The `plantlike` extension visually passes through any nodes above the
  940. base cube without affecting them.
  941. * The base cube texture tiles are defined as normal, the `plantlike`
  942. extension uses the defined special tile, for example:
  943. `special_tiles = {{name = "default_papyrus.png"}},`
  944. `*_optional` drawtypes need less rendering time if deactivated
  945. (always client-side).
  946. Node boxes
  947. ----------
  948. Node selection boxes are defined using "node boxes".
  949. A nodebox is defined as any of:
  950. {
  951. -- A normal cube; the default in most things
  952. type = "regular"
  953. }
  954. {
  955. -- A fixed box (or boxes) (facedir param2 is used, if applicable)
  956. type = "fixed",
  957. fixed = box OR {box1, box2, ...}
  958. }
  959. {
  960. -- A variable height box (or boxes) with the top face position defined
  961. -- by the node parameter 'leveled = ', or if 'paramtype2 == "leveled"'
  962. -- by param2.
  963. -- Other faces are defined by 'fixed = {}' as with 'type = "fixed"'.
  964. type = "leveled",
  965. fixed = box OR {box1, box2, ...}
  966. }
  967. {
  968. -- A box like the selection box for torches
  969. -- (wallmounted param2 is used, if applicable)
  970. type = "wallmounted",
  971. wall_top = box,
  972. wall_bottom = box,
  973. wall_side = box
  974. }
  975. {
  976. -- A node that has optional boxes depending on neighbouring nodes'
  977. -- presence and type. See also `connects_to`.
  978. type = "connected",
  979. fixed = box OR {box1, box2, ...}
  980. connect_top = box OR {box1, box2, ...}
  981. connect_bottom = box OR {box1, box2, ...}
  982. connect_front = box OR {box1, box2, ...}
  983. connect_left = box OR {box1, box2, ...}
  984. connect_back = box OR {box1, box2, ...}
  985. connect_right = box OR {box1, box2, ...}
  986. -- The following `disconnected_*` boxes are the opposites of the
  987. -- `connect_*` ones above, i.e. when a node has no suitable neighbour
  988. -- on the respective side, the corresponding disconnected box is drawn.
  989. disconnected_top = box OR {box1, box2, ...}
  990. disconnected_bottom = box OR {box1, box2, ...}
  991. disconnected_front = box OR {box1, box2, ...}
  992. disconnected_left = box OR {box1, box2, ...}
  993. disconnected_back = box OR {box1, box2, ...}
  994. disconnected_right = box OR {box1, box2, ...}
  995. disconnected = box OR {box1, box2, ...} -- when there is *no* neighbour
  996. disconnected_sides = box OR {box1, box2, ...} -- when there are *no*
  997. -- neighbours to the sides
  998. }
  999. A `box` is defined as:
  1000. {x1, y1, z1, x2, y2, z2}
  1001. A box of a regular node would look like:
  1002. {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  1003. To avoid collision issues, keep each value within the range of +/- 1.45.
  1004. This also applies to leveled nodeboxes, where the final height shall not
  1005. exceed this soft limit.
  1006. Map terminology and coordinates
  1007. ===============================
  1008. Nodes, mapblocks, mapchunks
  1009. ---------------------------
  1010. A 'node' is the fundamental cubic unit of a world and appears to a player as
  1011. roughly 1x1x1 meters in size.
  1012. A 'mapblock' (often abbreviated to 'block') is 16x16x16 nodes and is the
  1013. fundamental region of a world that is stored in the world database, sent to
  1014. clients and handled by many parts of the engine.
  1015. 'mapblock' is preferred terminology to 'block' to help avoid confusion with
  1016. 'node', however 'block' often appears in the API.
  1017. A 'mapchunk' (sometimes abbreviated to 'chunk') is usually 5x5x5 mapblocks
  1018. (80x80x80 nodes) and is the volume of world generated in one operation by
  1019. the map generator.
  1020. The size in mapblocks has been chosen to optimise map generation.
  1021. Coordinates
  1022. -----------
  1023. ### Orientation of axes
  1024. For node and mapblock coordinates, +X is East, +Y is up, +Z is North.
  1025. ### Node coordinates
  1026. Almost all positions used in the API use node coordinates.
  1027. ### Mapblock coordinates
  1028. Occasionally the API uses 'blockpos' which refers to mapblock coordinates that
  1029. specify a particular mapblock.
  1030. For example blockpos (0,0,0) specifies the mapblock that extends from
  1031. node position (0,0,0) to node position (15,15,15).
  1032. #### Converting node position to the containing blockpos
  1033. To calculate the blockpos of the mapblock that contains the node at 'nodepos',
  1034. for each axis:
  1035. * blockpos = math.floor(nodepos / 16)
  1036. #### Converting blockpos to min/max node positions
  1037. To calculate the min/max node positions contained in the mapblock at 'blockpos',
  1038. for each axis:
  1039. * Minimum:
  1040. nodepos = blockpos * 16
  1041. * Maximum:
  1042. nodepos = blockpos * 16 + 15
  1043. HUD
  1044. ===
  1045. HUD element types
  1046. -----------------
  1047. The position field is used for all element types.
  1048. To account for differing resolutions, the position coordinates are the
  1049. percentage of the screen, ranging in value from `0` to `1`.
  1050. The `name` field is not yet used, but should contain a description of what the
  1051. HUD element represents.
  1052. The `direction` field is the direction in which something is drawn.
  1053. `0` draws from left to right, `1` draws from right to left, `2` draws from
  1054. top to bottom, and `3` draws from bottom to top.
  1055. The `alignment` field specifies how the item will be aligned. It is a table
  1056. where `x` and `y` range from `-1` to `1`, with `0` being central. `-1` is
  1057. moved to the left/up, and `1` is to the right/down. Fractional values can be
  1058. used.
  1059. The `offset` field specifies a pixel offset from the position. Contrary to
  1060. position, the offset is not scaled to screen size. This allows for some
  1061. precisely positioned items in the HUD.
  1062. **Note**: `offset` _will_ adapt to screen DPI as well as user defined scaling
  1063. factor!
  1064. The `z_index` field specifies the order of HUD elements from back to front.
  1065. Lower z-index elements are displayed behind higher z-index elements. Elements
  1066. with same z-index are displayed in an arbitrary order. Default 0.
  1067. Supports negative values. By convention, the following values are recommended:
  1068. * -400: Graphical effects, such as vignette
  1069. * -300: Name tags, waypoints
  1070. * -200: Wieldhand
  1071. * -100: Things that block the player's view, e.g. masks
  1072. * 0: Default. For standard in-game HUD elements like crosshair, hotbar,
  1073. minimap, builtin statbars, etc.
  1074. * 100: Temporary text messages or notification icons
  1075. * 1000: Full-screen effects such as full-black screen or credits.
  1076. This includes effects that cover the entire screen
  1077. If your HUD element doesn't fit into any category, pick a number
  1078. between the suggested values
  1079. Below are the specific uses for fields in each type; fields not listed for that
  1080. type are ignored.
  1081. ### `image`
  1082. Displays an image on the HUD.
  1083. * `scale`: The scale of the image, with 1 being the original texture size.
  1084. Only the X coordinate scale is used (positive values).
  1085. Negative values represent that percentage of the screen it
  1086. should take; e.g. `x=-100` means 100% (width).
  1087. * `text`: The name of the texture that is displayed.
  1088. * `alignment`: The alignment of the image.
  1089. * `offset`: offset in pixels from position.
  1090. ### `text`
  1091. Displays text on the HUD.
  1092. * `scale`: Defines the bounding rectangle of the text.
  1093. A value such as `{x=100, y=100}` should work.
  1094. * `text`: The text to be displayed in the HUD element.
  1095. * `number`: An integer containing the RGB value of the color used to draw the
  1096. text. Specify `0xFFFFFF` for white text, `0xFF0000` for red, and so on.
  1097. * `alignment`: The alignment of the text.
  1098. * `offset`: offset in pixels from position.
  1099. * `size`: size of the text.
  1100. The player-set font size is multiplied by size.x (y value isn't used).
  1101. * `style`: determines font style
  1102. Bitfield with 1 = bold, 2 = italic, 4 = monospace
  1103. ### `statbar`
  1104. Displays a horizontal bar made up of half-images with an optional background.
  1105. * `text`: The name of the texture to use.
  1106. * `text2`: Optional texture name to enable a background / "off state"
  1107. texture (useful to visualize the maximal value). Both textures
  1108. must have the same size.
  1109. * `number`: The number of half-textures that are displayed.
  1110. If odd, will end with a vertically center-split texture.
  1111. * `item`: Same as `number` but for the "off state" texture
  1112. * `direction`: To which direction the images will extend to
  1113. * `offset`: offset in pixels from position.
  1114. * `size`: If used, will force full-image size to this value (override texture
  1115. pack image size)
  1116. ### `inventory`
  1117. * `text`: The name of the inventory list to be displayed.
  1118. * `number`: Number of items in the inventory to be displayed.
  1119. * `item`: Position of item that is selected.
  1120. * `direction`: Direction the list will be displayed in
  1121. * `offset`: offset in pixels from position.
  1122. ### `waypoint`
  1123. Displays distance to selected world position.
  1124. * `name`: The name of the waypoint.
  1125. * `text`: Distance suffix. Can be blank.
  1126. * `precision`: Waypoint precision, integer >= 0. Defaults to 10.
  1127. If set to 0, distance is not shown. Shown value is `floor(distance*precision)/precision`.
  1128. When the precision is an integer multiple of 10, there will be `log_10(precision)` digits after the decimal point.
  1129. `precision = 1000`, for example, will show 3 decimal places (eg: `0.999`).
  1130. `precision = 2` will show multiples of `0.5`; precision = 5 will show multiples of `0.2` and so on:
  1131. `precision = n` will show multiples of `1/n`
  1132. * `number:` An integer containing the RGB value of the color used to draw the
  1133. text.
  1134. * `world_pos`: World position of the waypoint.
  1135. * `offset`: offset in pixels from position.
  1136. * `alignment`: The alignment of the waypoint.
  1137. ### `image_waypoint`
  1138. Same as `image`, but does not accept a `position`; the position is instead determined by `world_pos`, the world position of the waypoint.
  1139. * `scale`: The scale of the image, with 1 being the original texture size.
  1140. Only the X coordinate scale is used (positive values).
  1141. Negative values represent that percentage of the screen it
  1142. should take; e.g. `x=-100` means 100% (width).
  1143. * `text`: The name of the texture that is displayed.
  1144. * `alignment`: The alignment of the image.
  1145. * `world_pos`: World position of the waypoint.
  1146. * `offset`: offset in pixels from position.
  1147. ### `compass`
  1148. Displays an image oriented or translated according to current heading direction.
  1149. * `size`: The size of this element. Negative values represent percentage
  1150. of the screen; e.g. `x=-100` means 100% (width).
  1151. * `scale`: Scale of the translated image (used only for dir = 2 or dir = 3).
  1152. * `text`: The name of the texture to use.
  1153. * `alignment`: The alignment of the image.
  1154. * `offset`: Offset in pixels from position.
  1155. * `direction`: How the image is rotated/translated:
  1156. * 0 - Rotate as heading direction
  1157. * 1 - Rotate in reverse direction
  1158. * 2 - Translate as landscape direction
  1159. * 3 - Translate in reverse direction
  1160. If translation is chosen, texture is repeated horizontally to fill the whole element.
  1161. ### `minimap`
  1162. Displays a minimap on the HUD.
  1163. * `size`: Size of the minimap to display. Minimap should be a square to avoid
  1164. distortion.
  1165. * `alignment`: The alignment of the minimap.
  1166. * `offset`: offset in pixels from position.
  1167. Representations of simple things
  1168. ================================
  1169. Vector (ie. a position)
  1170. -----------------------
  1171. vector.new(x, y, z)
  1172. See [Spatial Vectors] for details.
  1173. `pointed_thing`
  1174. ---------------
  1175. * `{type="nothing"}`
  1176. * `{type="node", under=pos, above=pos}`
  1177. * Indicates a pointed node selection box.
  1178. * `under` refers to the node position behind the pointed face.
  1179. * `above` refers to the node position in front of the pointed face.
  1180. * `{type="object", ref=ObjectRef}`
  1181. Exact pointing location (currently only `Raycast` supports these fields):
  1182. * `pointed_thing.intersection_point`: The absolute world coordinates of the
  1183. point on the selection box which is pointed at. May be in the selection box
  1184. if the pointer is in the box too.
  1185. * `pointed_thing.box_id`: The ID of the pointed selection box (counting starts
  1186. from 1).
  1187. * `pointed_thing.intersection_normal`: Unit vector, points outwards of the
  1188. selected selection box. This specifies which face is pointed at.
  1189. Is a null vector `vector.zero()` when the pointer is inside the selection box.
  1190. Flag Specifier Format
  1191. =====================
  1192. Flags using the standardized flag specifier format can be specified in either
  1193. of two ways, by string or table.
  1194. The string format is a comma-delimited set of flag names; whitespace and
  1195. unrecognized flag fields are ignored. Specifying a flag in the string sets the
  1196. flag, and specifying a flag prefixed by the string `"no"` explicitly
  1197. clears the flag from whatever the default may be.
  1198. In addition to the standard string flag format, the schematic flags field can
  1199. also be a table of flag names to boolean values representing whether or not the
  1200. flag is set. Additionally, if a field with the flag name prefixed with `"no"`
  1201. is present, mapped to a boolean of any value, the specified flag is unset.
  1202. E.g. A flag field of value
  1203. {place_center_x = true, place_center_y=false, place_center_z=true}
  1204. is equivalent to
  1205. {place_center_x = true, noplace_center_y=true, place_center_z=true}
  1206. which is equivalent to
  1207. "place_center_x, noplace_center_y, place_center_z"
  1208. or even
  1209. "place_center_x, place_center_z"
  1210. since, by default, no schematic attributes are set.
  1211. Items
  1212. =====
  1213. Items are things that can be held by players, dropped in the map and
  1214. stored in inventories.
  1215. Items come in the form of item stacks, which are collections of equal
  1216. items that occupy a single inventory slot.
  1217. Item types
  1218. ----------
  1219. There are three kinds of items: nodes, tools and craftitems.
  1220. * Node: Placeable item form of a node in the world's voxel grid
  1221. * Tool: Has a changable wear property but cannot be stacked
  1222. * Craftitem: Has no special properties
  1223. Every registered node (the voxel in the world) has a corresponding
  1224. item form (the thing in your inventory) that comes along with it.
  1225. This item form can be placed which will create a node in the
  1226. world (by default).
  1227. Both the 'actual' node and its item form share the same identifier.
  1228. For all practical purposes, you can treat the node and its item form
  1229. interchangeably. We usually just say 'node' to the item form of
  1230. the node as well.
  1231. Note the definition of tools is purely technical. The only really
  1232. unique thing about tools is their wear, and that's basically it.
  1233. Beyond that, you can't make any gameplay-relevant assumptions
  1234. about tools or non-tools. It is perfectly valid to register something
  1235. that acts as tool in a gameplay sense as a craftitem, and vice-versa.
  1236. Craftitems can be used for items that neither need to be a node
  1237. nor a tool.
  1238. Amount and wear
  1239. ---------------
  1240. All item stacks have an amount between 0 and 65535. It is 1 by
  1241. default. Tool item stacks can not have an amount greater than 1.
  1242. Tools use a wear (damage) value ranging from 0 to 65535. The
  1243. value 0 is the default and is used for unworn tools. The values
  1244. 1 to 65535 are used for worn tools, where a higher value stands for
  1245. a higher wear. Non-tools technically also have a wear property,
  1246. but it is always 0. There is also a special 'toolrepair' crafting
  1247. recipe that is only available to tools.
  1248. Item formats
  1249. ------------
  1250. Items and item stacks can exist in three formats: Serializes, table format
  1251. and `ItemStack`.
  1252. When an item must be passed to a function, it can usually be in any of
  1253. these formats.
  1254. ### Serialized
  1255. This is called "stackstring" or "itemstring". It is a simple string with
  1256. 1-4 components:
  1257. 1. Full item identifier ("item name")
  1258. 2. Optional amount
  1259. 3. Optional wear value
  1260. 4. Optional item metadata
  1261. Syntax:
  1262. <identifier> [<amount>[ <wear>[ <metadata>]]]
  1263. Examples:
  1264. * `"default:apple"`: 1 apple
  1265. * `"default:dirt 5"`: 5 dirt
  1266. * `"default:pick_stone"`: a new stone pickaxe
  1267. * `"default:pick_wood 1 21323"`: a wooden pickaxe, ca. 1/3 worn out
  1268. * `[[default:pick_wood 1 21323 "\u0001description\u0002My worn out pick\u0003"]]`:
  1269. * a wooden pickaxe from the `default` mod,
  1270. * amount must be 1 (pickaxe is a tool), ca. 1/3 worn out (it's a tool),
  1271. * with the `description` field set to `"My worn out pick"` in its metadata
  1272. * `[[default:dirt 5 0 "\u0001description\u0002Special dirt\u0003"]]`:
  1273. * analogeous to the above example
  1274. * note how the wear is set to `0` as dirt is not a tool
  1275. You should ideally use the `ItemStack` format to build complex item strings
  1276. (especially if they use item metadata)
  1277. without relying on the serialization format. Example:
  1278. local stack = ItemStack("default:pick_wood")
  1279. stack:set_wear(21323)
  1280. stack:get_meta():set_string("description", "My worn out pick")
  1281. local itemstring = stack:to_string()
  1282. Additionally the methods `minetest.itemstring_with_palette(item, palette_index)`
  1283. and `minetest.itemstring_with_color(item, colorstring)` may be used to create
  1284. item strings encoding color information in their metadata.
  1285. ### Table format
  1286. Examples:
  1287. 5 dirt nodes:
  1288. {name="default:dirt", count=5, wear=0, metadata=""}
  1289. A wooden pick about 1/3 worn out:
  1290. {name="default:pick_wood", count=1, wear=21323, metadata=""}
  1291. An apple:
  1292. {name="default:apple", count=1, wear=0, metadata=""}
  1293. ### `ItemStack`
  1294. A native C++ format with many helper methods. Useful for converting
  1295. between formats. See the [Class reference] section for details.
  1296. Groups
  1297. ======
  1298. In a number of places, there is a group table. Groups define the
  1299. properties of a thing (item, node, armor of entity, tool capabilities)
  1300. in such a way that the engine and other mods can can interact with
  1301. the thing without actually knowing what the thing is.
  1302. Usage
  1303. -----
  1304. Groups are stored in a table, having the group names with keys and the
  1305. group ratings as values. Group ratings are integer values within the
  1306. range [-32767, 32767]. For example:
  1307. -- Default dirt
  1308. groups = {crumbly=3, soil=1}
  1309. -- A more special dirt-kind of thing
  1310. groups = {crumbly=2, soil=1, level=2, outerspace=1}
  1311. Groups always have a rating associated with them. If there is no
  1312. useful meaning for a rating for an enabled group, it shall be `1`.
  1313. When not defined, the rating of a group defaults to `0`. Thus when you
  1314. read groups, you must interpret `nil` and `0` as the same value, `0`.
  1315. You can read the rating of a group for an item or a node by using
  1316. minetest.get_item_group(itemname, groupname)
  1317. Groups of items
  1318. ---------------
  1319. Groups of items can define what kind of an item it is (e.g. wool).
  1320. Groups of nodes
  1321. ---------------
  1322. In addition to the general item things, groups are used to define whether
  1323. a node is destroyable and how long it takes to destroy by a tool.
  1324. Groups of entities
  1325. ------------------
  1326. For entities, groups are, as of now, used only for calculating damage.
  1327. The rating is the percentage of damage caused by items with this damage group.
  1328. See [Entity damage mechanism].
  1329. object.get_armor_groups() --> a group-rating table (e.g. {fleshy=100})
  1330. object.set_armor_groups({fleshy=30, cracky=80})
  1331. Groups of tool capabilities
  1332. ---------------------------
  1333. Groups in tool capabilities define which groups of nodes and entities they
  1334. are effective towards.
  1335. Groups in crafting recipes
  1336. --------------------------
  1337. An example: Make meat soup from any meat, any water and any bowl:
  1338. {
  1339. output = "food:meat_soup_raw",
  1340. recipe = {
  1341. {"group:meat"},
  1342. {"group:water"},
  1343. {"group:bowl"},
  1344. },
  1345. }
  1346. Another example: Make red wool from white wool and red dye:
  1347. {
  1348. type = "shapeless",
  1349. output = "wool:red",
  1350. recipe = {"wool:white", "group:dye,basecolor_red"},
  1351. }
  1352. Special groups
  1353. --------------
  1354. The asterisk `(*)` after a group name describes that there is no engine
  1355. functionality bound to it, and implementation is left up as a suggestion
  1356. to games.
  1357. ### Node and item groups
  1358. * `not_in_creative_inventory`: (*) Special group for inventory mods to indicate
  1359. that the item should be hidden in item lists.
  1360. ### Node-only groups
  1361. * `attached_node`: if the node under it is not a walkable block the node will be
  1362. dropped as an item. If the node is wallmounted the wallmounted direction is
  1363. checked.
  1364. * `bouncy`: value is bounce speed in percent
  1365. * `connect_to_raillike`: makes nodes of raillike drawtype with same group value
  1366. connect to each other
  1367. * `dig_immediate`: Player can always pick up node without reducing tool wear
  1368. * `2`: the node always gets the digging time 0.5 seconds (rail, sign)
  1369. * `3`: the node always gets the digging time 0 seconds (torch)
  1370. * `disable_jump`: Player (and possibly other things) cannot jump from node
  1371. or if their feet are in the node. Note: not supported for `new_move = false`
  1372. * `fall_damage_add_percent`: modifies the fall damage suffered when hitting
  1373. the top of this node. There's also an armor group with the same name.
  1374. The final player damage is determined by the following formula:
  1375. damage =
  1376. collision speed
  1377. * ((node_fall_damage_add_percent + 100) / 100) -- node group
  1378. * ((player_fall_damage_add_percent + 100) / 100) -- player armor group
  1379. - (14) -- constant tolerance
  1380. Negative damage values are discarded as no damage.
  1381. * `falling_node`: if there is no walkable block under the node it will fall
  1382. * `float`: the node will not fall through liquids (`liquidtype ~= "none"`)
  1383. * `level`: Can be used to give an additional sense of progression in the game.
  1384. * A larger level will cause e.g. a weapon of a lower level make much less
  1385. damage, and get worn out much faster, or not be able to get drops
  1386. from destroyed nodes.
  1387. * `0` is something that is directly accessible at the start of gameplay
  1388. * There is no upper limit
  1389. * See also: `leveldiff` in [Tool Capabilities]
  1390. * `slippery`: Players and items will slide on the node.
  1391. Slipperiness rises steadily with `slippery` value, starting at 1.
  1392. ### Tool-only groups
  1393. * `disable_repair`: If set to 1 for a tool, it cannot be repaired using the
  1394. `"toolrepair"` crafting recipe
  1395. ### `ObjectRef` armor groups
  1396. * `immortal`: Skips all damage and breath handling for an object. This group
  1397. will also hide the integrated HUD status bars for players. It is
  1398. automatically set to all players when damage is disabled on the server and
  1399. cannot be reset (subject to change).
  1400. * `fall_damage_add_percent`: Modifies the fall damage suffered by players
  1401. when they hit the ground. It is analog to the node group with the same
  1402. name. See the node group above for the exact calculation.
  1403. * `punch_operable`: For entities; disables the regular damage mechanism for
  1404. players punching it by hand or a non-tool item, so that it can do something
  1405. else than take damage.
  1406. Known damage and digging time defining groups
  1407. ---------------------------------------------
  1408. * `crumbly`: dirt, sand
  1409. * `cracky`: tough but crackable stuff like stone.
  1410. * `snappy`: something that can be cut using things like scissors, shears,
  1411. bolt cutters and the like, e.g. leaves, small plants, wire, sheets of metal
  1412. * `choppy`: something that can be cut using force; e.g. trees, wooden planks
  1413. * `fleshy`: Living things like animals and the player. This could imply
  1414. some blood effects when hitting.
  1415. * `explody`: Especially prone to explosions
  1416. * `oddly_breakable_by_hand`:
  1417. Can be added to nodes that shouldn't logically be breakable by the
  1418. hand but are. Somewhat similar to `dig_immediate`, but times are more
  1419. like `{[1]=3.50,[2]=2.00,[3]=0.70}` and this does not override the
  1420. digging speed of an item if it can dig at a faster speed than this
  1421. suggests for the hand.
  1422. Examples of custom groups
  1423. -------------------------
  1424. Item groups are often used for defining, well, _groups of items_.
  1425. * `meat`: any meat-kind of a thing (rating might define the size or healing
  1426. ability or be irrelevant -- it is not defined as of yet)
  1427. * `eatable`: anything that can be eaten. Rating might define HP gain in half
  1428. hearts.
  1429. * `flammable`: can be set on fire. Rating might define the intensity of the
  1430. fire, affecting e.g. the speed of the spreading of an open fire.
  1431. * `wool`: any wool (any origin, any color)
  1432. * `metal`: any metal
  1433. * `weapon`: any weapon
  1434. * `heavy`: anything considerably heavy
  1435. Digging time calculation specifics
  1436. ----------------------------------
  1437. Groups such as `crumbly`, `cracky` and `snappy` are used for this
  1438. purpose. Rating is `1`, `2` or `3`. A higher rating for such a group implies
  1439. faster digging time.
  1440. The `level` group is used to limit the toughness of nodes an item capable
  1441. of digging can dig and to scale the digging times / damage to a greater extent.
  1442. **Please do understand this**, otherwise you cannot use the system to it's
  1443. full potential.
  1444. Items define their properties by a list of parameters for groups. They
  1445. cannot dig other groups; thus it is important to use a standard bunch of
  1446. groups to enable interaction with items.
  1447. Tool Capabilities
  1448. =================
  1449. 'Tool capabilities' is a property of items that defines two things:
  1450. 1) Which nodes it can dig and how fast
  1451. 2) Which objects it can hurt by punching and by how much
  1452. Tool capabilities are available for all items, not just tools.
  1453. But only tools can receive wear from digging and punching.
  1454. Missing or incomplete tool capabilities will default to the
  1455. player's hand.
  1456. Tool capabilities definition
  1457. ----------------------------
  1458. Tool capabilities define:
  1459. * Full punch interval
  1460. * Maximum drop level
  1461. * For an arbitrary list of node groups:
  1462. * Uses (until the tool breaks)
  1463. * Maximum level (usually `0`, `1`, `2` or `3`)
  1464. * Digging times
  1465. * Damage groups
  1466. * Punch attack uses (until the tool breaks)
  1467. ### Full punch interval `full_punch_interval`
  1468. When used as a weapon, the item will do full damage if this time is spent
  1469. between punches. If e.g. half the time is spent, the item will do half
  1470. damage.
  1471. ### Maximum drop level `max_drop_level`
  1472. Suggests the maximum level of node, when dug with the item, that will drop
  1473. its useful item. (e.g. iron ore to drop a lump of iron).
  1474. This value is not used in the engine; it is the responsibility of the game/mod
  1475. code to implement this.
  1476. ### Uses `uses` (tools only)
  1477. Determines how many uses the tool has when it is used for digging a node,
  1478. of this group, of the maximum level. The maximum supported number of
  1479. uses is 65535. The special number 0 is used for infinite uses.
  1480. For lower leveled nodes, the use count is multiplied by `3^leveldiff`.
  1481. `leveldiff` is the difference of the tool's `maxlevel` `groupcaps` and the
  1482. node's `level` group. The node cannot be dug if `leveldiff` is less than zero.
  1483. * `uses=10, leveldiff=0`: actual uses: 10
  1484. * `uses=10, leveldiff=1`: actual uses: 30
  1485. * `uses=10, leveldiff=2`: actual uses: 90
  1486. For non-tools, this has no effect.
  1487. ### Maximum level `maxlevel`
  1488. Tells what is the maximum level of a node of this group that the item will
  1489. be able to dig.
  1490. ### Digging times `times`
  1491. List of digging times for different ratings of the group, for nodes of the
  1492. maximum level.
  1493. For example, as a Lua table, `times={[2]=2.00, [3]=0.70}`. This would
  1494. result in the item to be able to dig nodes that have a rating of `2` or `3`
  1495. for this group, and unable to dig the rating `1`, which is the toughest.
  1496. Unless there is a matching group that enables digging otherwise.
  1497. If the result digging time is 0, a delay of 0.15 seconds is added between
  1498. digging nodes; If the player releases LMB after digging, this delay is set to 0,
  1499. i.e. players can more quickly click the nodes away instead of holding LMB.
  1500. ### Damage groups
  1501. List of damage for groups of entities. See [Entity damage mechanism].
  1502. ### Punch attack uses (tools only)
  1503. Determines how many uses (before breaking) the tool has when dealing damage
  1504. to an object, when the full punch interval (see above) was always
  1505. waited out fully.
  1506. Wear received by the tool is proportional to the time spent, scaled by
  1507. the full punch interval.
  1508. For non-tools, this has no effect.
  1509. Example definition of the capabilities of an item
  1510. -------------------------------------------------
  1511. tool_capabilities = {
  1512. groupcaps={
  1513. crumbly={maxlevel=2, uses=20, times={[1]=1.60, [2]=1.20, [3]=0.80}}
  1514. },
  1515. }
  1516. This makes the item capable of digging nodes that fulfil both of these:
  1517. * Have the `crumbly` group
  1518. * Have a `level` group less or equal to `2`
  1519. Table of resulting digging times:
  1520. crumbly 0 1 2 3 4 <- level
  1521. -> 0 - - - - -
  1522. 1 0.80 1.60 1.60 - -
  1523. 2 0.60 1.20 1.20 - -
  1524. 3 0.40 0.80 0.80 - -
  1525. level diff: 2 1 0 -1 -2
  1526. Table of resulting tool uses:
  1527. -> 0 - - - - -
  1528. 1 180 60 20 - -
  1529. 2 180 60 20 - -
  1530. 3 180 60 20 - -
  1531. **Notes**:
  1532. * At `crumbly==0`, the node is not diggable.
  1533. * At `crumbly==3`, the level difference digging time divider kicks in and makes
  1534. easy nodes to be quickly breakable.
  1535. * At `level > 2`, the node is not diggable, because it's `level > maxlevel`
  1536. Entity damage mechanism
  1537. =======================
  1538. Damage calculation:
  1539. damage = 0
  1540. foreach group in cap.damage_groups:
  1541. damage += cap.damage_groups[group]
  1542. * limit(actual_interval / cap.full_punch_interval, 0.0, 1.0)
  1543. * (object.armor_groups[group] / 100.0)
  1544. -- Where object.armor_groups[group] is 0 for inexistent values
  1545. return damage
  1546. Client predicts damage based on damage groups. Because of this, it is able to
  1547. give an immediate response when an entity is damaged or dies; the response is
  1548. pre-defined somehow (e.g. by defining a sprite animation) (not implemented;
  1549. TODO).
  1550. Currently a smoke puff will appear when an entity dies.
  1551. The group `immortal` completely disables normal damage.
  1552. Entities can define a special armor group, which is `punch_operable`. This
  1553. group disables the regular damage mechanism for players punching it by hand or
  1554. a non-tool item, so that it can do something else than take damage.
  1555. On the Lua side, every punch calls:
  1556. entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction,
  1557. damage)
  1558. This should never be called directly, because damage is usually not handled by
  1559. the entity itself.
  1560. * `puncher` is the object performing the punch. Can be `nil`. Should never be
  1561. accessed unless absolutely required, to encourage interoperability.
  1562. * `time_from_last_punch` is time from last punch (by `puncher`) or `nil`.
  1563. * `tool_capabilities` can be `nil`.
  1564. * `direction` is a unit vector, pointing from the source of the punch to
  1565. the punched object.
  1566. * `damage` damage that will be done to entity
  1567. Return value of this function will determine if damage is done by this function
  1568. (retval true) or shall be done by engine (retval false)
  1569. To punch an entity/object in Lua, call:
  1570. object:punch(puncher, time_from_last_punch, tool_capabilities, direction)
  1571. * Return value is tool wear.
  1572. * Parameters are equal to the above callback.
  1573. * If `direction` equals `nil` and `puncher` does not equal `nil`, `direction`
  1574. will be automatically filled in based on the location of `puncher`.
  1575. Metadata
  1576. ========
  1577. Node Metadata
  1578. -------------
  1579. The instance of a node in the world normally only contains the three values
  1580. mentioned in [Nodes]. However, it is possible to insert extra data into a node.
  1581. It is called "node metadata"; See `NodeMetaRef`.
  1582. Node metadata contains two things:
  1583. * A key-value store
  1584. * An inventory
  1585. Some of the values in the key-value store are handled specially:
  1586. * `formspec`: Defines an inventory menu that is opened with the
  1587. 'place/use' key. Only works if no `on_rightclick` was
  1588. defined for the node. See also [Formspec].
  1589. * `infotext`: Text shown on the screen when the node is pointed at.
  1590. Line-breaks will be applied automatically.
  1591. If the infotext is very long, it will be truncated.
  1592. Example:
  1593. local meta = minetest.get_meta(pos)
  1594. meta:set_string("formspec",
  1595. "size[8,9]"..
  1596. "list[context;main;0,0;8,4;]"..
  1597. "list[current_player;main;0,5;8,4;]")
  1598. meta:set_string("infotext", "Chest");
  1599. local inv = meta:get_inventory()
  1600. inv:set_size("main", 8*4)
  1601. print(dump(meta:to_table()))
  1602. meta:from_table({
  1603. inventory = {
  1604. main = {[1] = "default:dirt", [2] = "", [3] = "", [4] = "",
  1605. [5] = "", [6] = "", [7] = "", [8] = "", [9] = "",
  1606. [10] = "", [11] = "", [12] = "", [13] = "",
  1607. [14] = "default:cobble", [15] = "", [16] = "", [17] = "",
  1608. [18] = "", [19] = "", [20] = "default:cobble", [21] = "",
  1609. [22] = "", [23] = "", [24] = "", [25] = "", [26] = "",
  1610. [27] = "", [28] = "", [29] = "", [30] = "", [31] = "",
  1611. [32] = ""}
  1612. },
  1613. fields = {
  1614. formspec = "size[8,9]list[context;main;0,0;8,4;]list[current_player;main;0,5;8,4;]",
  1615. infotext = "Chest"
  1616. }
  1617. })
  1618. Item Metadata
  1619. -------------
  1620. Item stacks can store metadata too. See [`ItemStackMetaRef`].
  1621. Item metadata only contains a key-value store.
  1622. Some of the values in the key-value store are handled specially:
  1623. * `description`: Set the item stack's description.
  1624. See also: `get_description` in [`ItemStack`]
  1625. * `short_description`: Set the item stack's short description.
  1626. See also: `get_short_description` in [`ItemStack`]
  1627. * `color`: A `ColorString`, which sets the stack's color.
  1628. * `palette_index`: If the item has a palette, this is used to get the
  1629. current color from the palette.
  1630. * `count_meta`: Replace the displayed count with any string.
  1631. * `count_alignment`: Set the alignment of the displayed count value. This is an
  1632. int value. The lowest 2 bits specify the alignment in x-direction, the 3rd and
  1633. 4th bit specify the alignment in y-direction:
  1634. 0 = default, 1 = left / up, 2 = middle, 3 = right / down
  1635. The default currently is the same as right/down.
  1636. Example: 6 = 2 + 1*4 = middle,up
  1637. Example:
  1638. local meta = stack:get_meta()
  1639. meta:set_string("key", "value")
  1640. print(dump(meta:to_table()))
  1641. Example manipulations of "description" and expected output behaviors:
  1642. print(ItemStack("default:pick_steel"):get_description()) --> Steel Pickaxe
  1643. print(ItemStack("foobar"):get_description()) --> Unknown Item
  1644. local stack = ItemStack("default:stone")
  1645. stack:get_meta():set_string("description", "Custom description\nAnother line")
  1646. print(stack:get_description()) --> Custom description\nAnother line
  1647. print(stack:get_short_description()) --> Custom description
  1648. stack:get_meta():set_string("short_description", "Short")
  1649. print(stack:get_description()) --> Custom description\nAnother line
  1650. print(stack:get_short_description()) --> Short
  1651. print(ItemStack("mod:item_with_no_desc"):get_description()) --> mod:item_with_no_desc
  1652. Formspec
  1653. ========
  1654. Formspec defines a menu. This supports inventories and some of the
  1655. typical widgets like buttons, checkboxes, text input fields, etc.
  1656. It is a string, with a somewhat strange format.
  1657. A formspec is made out of formspec elements, which includes widgets
  1658. like buttons but also can be used to set stuff like background color.
  1659. Many formspec elements have a `name`, which is a unique identifier which
  1660. is used when the server receives user input. You must not use the name
  1661. "quit" for formspec elements.
  1662. Spaces and newlines can be inserted between the blocks, as is used in the
  1663. examples.
  1664. Position and size units are inventory slots unless the new coordinate system
  1665. is enabled. `X` and `Y` position the formspec element relative to the top left
  1666. of the menu or container. `W` and `H` are its width and height values.
  1667. If the new system is enabled, all elements have unified coordinates for all
  1668. elements with no padding or spacing in between. This is highly recommended
  1669. for new forms. See `real_coordinates[<bool>]` and `Migrating to Real
  1670. Coordinates`.
  1671. Inventories with a `player:<name>` inventory location are only sent to the
  1672. player named `<name>`.
  1673. When displaying text which can contain formspec code, e.g. text set by a player,
  1674. use `minetest.formspec_escape`.
  1675. For colored text you can use `minetest.colorize`.
  1676. Since formspec version 3, elements drawn in the order they are defined. All
  1677. background elements are drawn before all other elements.
  1678. **WARNING**: do _not_ use a element name starting with `key_`; those names are
  1679. reserved to pass key press events to formspec!
  1680. **WARNING**: Minetest allows you to add elements to every single formspec instance
  1681. using `player:set_formspec_prepend()`, which may be the reason backgrounds are
  1682. appearing when you don't expect them to, or why things are styled differently
  1683. to normal. See [`no_prepend[]`] and [Styling Formspecs].
  1684. Examples
  1685. --------
  1686. ### Chest
  1687. size[8,9]
  1688. list[context;main;0,0;8,4;]
  1689. list[current_player;main;0,5;8,4;]
  1690. ### Furnace
  1691. size[8,9]
  1692. list[context;fuel;2,3;1,1;]
  1693. list[context;src;2,1;1,1;]
  1694. list[context;dst;5,1;2,2;]
  1695. list[current_player;main;0,5;8,4;]
  1696. ### Minecraft-like player inventory
  1697. size[8,7.5]
  1698. image[1,0.6;1,2;player.png]
  1699. list[current_player;main;0,3.5;8,4;]
  1700. list[current_player;craft;3,0;3,3;]
  1701. list[current_player;craftpreview;7,1;1,1;]
  1702. Version History
  1703. ---------------
  1704. * Formspec version 1 (pre-5.1.0):
  1705. * (too much)
  1706. * Formspec version 2 (5.1.0):
  1707. * Forced real coordinates
  1708. * background9[]: 9-slice scaling parameters
  1709. * Formspec version 3 (5.2.0):
  1710. * Formspec elements are drawn in the order of definition
  1711. * bgcolor[]: use 3 parameters (bgcolor, formspec (now an enum), fbgcolor)
  1712. * box[] and image[] elements enable clipping by default
  1713. * new element: scroll_container[]
  1714. * Formspec version 4 (5.4.0):
  1715. * Allow dropdown indexing events
  1716. * Formspec version 5 (5.5.0):
  1717. * Added padding[] element
  1718. * Formspec version 6 (5.6.0):
  1719. * Add nine-slice images, animated_images, and fgimg_middle
  1720. Elements
  1721. --------
  1722. ### `formspec_version[<version>]`
  1723. * Set the formspec version to a certain number. If not specified,
  1724. version 1 is assumed.
  1725. * Must be specified before `size` element.
  1726. * Clients older than this version can neither show newer elements nor display
  1727. elements with new arguments correctly.
  1728. * Available since feature `formspec_version_element`.
  1729. * See also: [Version History]
  1730. ### `size[<W>,<H>,<fixed_size>]`
  1731. * Define the size of the menu in inventory slots
  1732. * `fixed_size`: `true`/`false` (optional)
  1733. * deprecated: `invsize[<W>,<H>;]`
  1734. ### `position[<X>,<Y>]`
  1735. * Must be used after `size` element.
  1736. * Defines the position on the game window of the formspec's `anchor` point.
  1737. * For X and Y, 0.0 and 1.0 represent opposite edges of the game window,
  1738. for example:
  1739. * [0.0, 0.0] sets the position to the top left corner of the game window.
  1740. * [1.0, 1.0] sets the position to the bottom right of the game window.
  1741. * Defaults to the center of the game window [0.5, 0.5].
  1742. ### `anchor[<X>,<Y>]`
  1743. * Must be used after both `size` and `position` (if present) elements.
  1744. * Defines the location of the anchor point within the formspec.
  1745. * For X and Y, 0.0 and 1.0 represent opposite edges of the formspec,
  1746. for example:
  1747. * [0.0, 1.0] sets the anchor to the bottom left corner of the formspec.
  1748. * [1.0, 0.0] sets the anchor to the top right of the formspec.
  1749. * Defaults to the center of the formspec [0.5, 0.5].
  1750. * `position` and `anchor` elements need suitable values to avoid a formspec
  1751. extending off the game window due to particular game window sizes.
  1752. ### `padding[<X>,<Y>]`
  1753. * Must be used after the `size`, `position`, and `anchor` elements (if present).
  1754. * Defines how much space is padded around the formspec if the formspec tries to
  1755. increase past the size of the screen and coordinates have to be shrunk.
  1756. * For X and Y, 0.0 represents no padding (the formspec can touch the edge of the
  1757. screen), and 0.5 represents half the screen (which forces the coordinate size
  1758. to 0). If negative, the formspec can extend off the edge of the screen.
  1759. * Defaults to [0.05, 0.05].
  1760. ### `no_prepend[]`
  1761. * Must be used after the `size`, `position`, `anchor`, and `padding` elements
  1762. (if present).
  1763. * Disables player:set_formspec_prepend() from applying to this formspec.
  1764. ### `real_coordinates[<bool>]`
  1765. * INFORMATION: Enable it automatically using `formspec_version` version 2 or newer.
  1766. * When set to true, all following formspec elements will use the new coordinate system.
  1767. * If used immediately after `size`, `position`, `anchor`, and `no_prepend` elements
  1768. (if present), the form size will use the new coordinate system.
  1769. * **Note**: Formspec prepends are not affected by the coordinates in the main form.
  1770. They must enable it explicitly.
  1771. * For information on converting forms to the new coordinate system, see `Migrating
  1772. to Real Coordinates`.
  1773. ### `container[<X>,<Y>]`
  1774. * Start of a container block, moves all physical elements in the container by
  1775. (X, Y).
  1776. * Must have matching `container_end`
  1777. * Containers can be nested, in which case the offsets are added
  1778. (child containers are relative to parent containers)
  1779. ### `container_end[]`
  1780. * End of a container, following elements are no longer relative to this
  1781. container.
  1782. ### `scroll_container[<X>,<Y>;<W>,<H>;<scrollbar name>;<orientation>;<scroll factor>]`
  1783. * Start of a scroll_container block. All contained elements will ...
  1784. * take the scroll_container coordinate as position origin,
  1785. * be additionally moved by the current value of the scrollbar with the name
  1786. `scrollbar name` times `scroll factor` along the orientation `orientation` and
  1787. * be clipped to the rectangle defined by `X`, `Y`, `W` and `H`.
  1788. * `orientation`: possible values are `vertical` and `horizontal`.
  1789. * `scroll factor`: optional, defaults to `0.1`.
  1790. * Nesting is possible.
  1791. * Some elements might work a little different if they are in a scroll_container.
  1792. * Note: If you want the scroll_container to actually work, you also need to add a
  1793. scrollbar element with the specified name. Furthermore, it is highly recommended
  1794. to use a scrollbaroptions element on this scrollbar.
  1795. ### `scroll_container_end[]`
  1796. * End of a scroll_container, following elements are no longer bound to this
  1797. container.
  1798. ### `list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;<starting item index>]`
  1799. * Show an inventory list if it has been sent to the client.
  1800. * If the inventory list changes (eg. it didn't exist before, it's resized, or its items
  1801. are moved) while the formspec is open, the formspec element may (but is not guaranteed
  1802. to) adapt to the new inventory list.
  1803. * Item slots are drawn in a grid from left to right, then up to down, ordered
  1804. according to the slot index.
  1805. * `W` and `H` are in inventory slots, not in coordinates.
  1806. * `starting item index` (Optional): The index of the first (upper-left) item to draw.
  1807. Indices start at `0`. Default is `0`.
  1808. * The number of shown slots is the minimum of `W*H` and the inventory list's size minus
  1809. `starting item index`.
  1810. * **Note**: With the new coordinate system, the spacing between inventory
  1811. slots is one-fourth the size of an inventory slot by default. Also see
  1812. [Styling Formspecs] for changing the size of slots and spacing.
  1813. ### `listring[<inventory location>;<list name>]`
  1814. * Appends to an internal ring of inventory lists.
  1815. * Shift-clicking on items in one element of the ring
  1816. will send them to the next inventory list inside the ring
  1817. * The first occurrence of an element inside the ring will
  1818. determine the inventory where items will be sent to
  1819. ### `listring[]`
  1820. * Shorthand for doing `listring[<inventory location>;<list name>]`
  1821. for the last two inventory lists added by list[...]
  1822. ### `listcolors[<slot_bg_normal>;<slot_bg_hover>]`
  1823. * Sets background color of slots as `ColorString`
  1824. * Sets background color of slots on mouse hovering
  1825. ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>]`
  1826. * Sets background color of slots as `ColorString`
  1827. * Sets background color of slots on mouse hovering
  1828. * Sets color of slots border
  1829. ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>;<tooltip_bgcolor>;<tooltip_fontcolor>]`
  1830. * Sets background color of slots as `ColorString`
  1831. * Sets background color of slots on mouse hovering
  1832. * Sets color of slots border
  1833. * Sets default background color of tooltips
  1834. * Sets default font color of tooltips
  1835. ### `tooltip[<gui_element_name>;<tooltip_text>;<bgcolor>;<fontcolor>]`
  1836. * Adds tooltip for an element
  1837. * `bgcolor` tooltip background color as `ColorString` (optional)
  1838. * `fontcolor` tooltip font color as `ColorString` (optional)
  1839. ### `tooltip[<X>,<Y>;<W>,<H>;<tooltip_text>;<bgcolor>;<fontcolor>]`
  1840. * Adds tooltip for an area. Other tooltips will take priority when present.
  1841. * `bgcolor` tooltip background color as `ColorString` (optional)
  1842. * `fontcolor` tooltip font color as `ColorString` (optional)
  1843. ### `image[<X>,<Y>;<W>,<H>;<texture name>;<middle>]`
  1844. * Show an image.
  1845. * `middle` (optional): Makes the image render in 9-sliced mode and defines the middle rect.
  1846. * Requires formspec version >= 6.
  1847. * See `background9[]` documentation for more information.
  1848. ### `animated_image[<X>,<Y>;<W>,<H>;<name>;<texture name>;<frame count>;<frame duration>;<frame start>;<middle>]`
  1849. * Show an animated image. The image is drawn like a "vertical_frames" tile
  1850. animation (See [Tile animation definition]), but uses a frame count/duration for simplicity
  1851. * `name`: Element name to send when an event occurs. The event value is the index of the current frame.
  1852. * `texture name`: The image to use.
  1853. * `frame count`: The number of frames animating the image.
  1854. * `frame duration`: Milliseconds between each frame. `0` means the frames don't advance.
  1855. * `frame start` (optional): The index of the frame to start on. Default `1`.
  1856. * `middle` (optional): Makes the image render in 9-sliced mode and defines the middle rect.
  1857. * Requires formspec version >= 6.
  1858. * See `background9[]` documentation for more information.
  1859. ### `model[<X>,<Y>;<W>,<H>;<name>;<mesh>;<textures>;<rotation X,Y>;<continuous>;<mouse control>;<frame loop range>;<animation speed>]`
  1860. * Show a mesh model.
  1861. * `name`: Element name that can be used for styling
  1862. * `mesh`: The mesh model to use.
  1863. * `textures`: The mesh textures to use according to the mesh materials.
  1864. Texture names must be separated by commas.
  1865. * `rotation {X,Y}` (Optional): Initial rotation of the camera.
  1866. The axes are euler angles in degrees.
  1867. * `continuous` (Optional): Whether the rotation is continuous. Default `false`.
  1868. * `mouse control` (Optional): Whether the model can be controlled with the mouse. Default `true`.
  1869. * `frame loop range` (Optional): Range of the animation frames.
  1870. * Defaults to the full range of all available frames.
  1871. * Syntax: `<begin>,<end>`
  1872. * `animation speed` (Optional): Sets the animation speed. Default 0 FPS.
  1873. ### `item_image[<X>,<Y>;<W>,<H>;<item name>]`
  1874. * Show an inventory image of registered item/node
  1875. ### `bgcolor[<bgcolor>;<fullscreen>;<fbgcolor>]`
  1876. * Sets background color of formspec.
  1877. * `bgcolor` and `fbgcolor` (optional) are `ColorString`s, they define the color
  1878. of the non-fullscreen and the fullscreen background.
  1879. * `fullscreen` (optional) can be one of the following:
  1880. * `false`: Only the non-fullscreen background color is drawn. (default)
  1881. * `true`: Only the fullscreen background color is drawn.
  1882. * `both`: The non-fullscreen and the fullscreen background color are drawn.
  1883. * `neither`: No background color is drawn.
  1884. * Note: Leave a parameter empty to not modify the value.
  1885. * Note: `fbgcolor`, leaving parameters empty and values for `fullscreen` that
  1886. are not bools are only available since formspec version 3.
  1887. ### `background[<X>,<Y>;<W>,<H>;<texture name>]`
  1888. * Example for formspec 8x4 in 16x resolution: image shall be sized
  1889. 8 times 16px times 4 times 16px.
  1890. ### `background[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>]`
  1891. * Example for formspec 8x4 in 16x resolution:
  1892. image shall be sized 8 times 16px times 4 times 16px
  1893. * If `auto_clip` is `true`, the background is clipped to the formspec size
  1894. (`x` and `y` are used as offset values, `w` and `h` are ignored)
  1895. ### `background9[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>;<middle>]`
  1896. * 9-sliced background. See https://en.wikipedia.org/wiki/9-slice_scaling
  1897. * Middle is a rect which defines the middle of the 9-slice.
  1898. * `x` - The middle will be x pixels from all sides.
  1899. * `x,y` - The middle will be x pixels from the horizontal and y from the vertical.
  1900. * `x,y,x2,y2` - The middle will start at x,y, and end at x2, y2. Negative x2 and y2 values
  1901. will be added to the width and height of the texture, allowing it to be used as the
  1902. distance from the far end.
  1903. * All numbers in middle are integers.
  1904. * If `auto_clip` is `true`, the background is clipped to the formspec size
  1905. (`x` and `y` are used as offset values, `w` and `h` are ignored)
  1906. * Available since formspec version 2
  1907. ### `pwdfield[<X>,<Y>;<W>,<H>;<name>;<label>]`
  1908. * Textual password style field; will be sent to server when a button is clicked
  1909. * When enter is pressed in field, fields.key_enter_field will be sent with the
  1910. name of this field.
  1911. * With the old coordinate system, fields are a set height, but will be vertically
  1912. centred on `H`. With the new coordinate system, `H` will modify the height.
  1913. * `name` is the name of the field as returned in fields to `on_receive_fields`
  1914. * `label`, if not blank, will be text printed on the top left above the field
  1915. * See `field_close_on_enter` to stop enter closing the formspec
  1916. ### `field[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
  1917. * Textual field; will be sent to server when a button is clicked
  1918. * When enter is pressed in field, `fields.key_enter_field` will be sent with
  1919. the name of this field.
  1920. * With the old coordinate system, fields are a set height, but will be vertically
  1921. centred on `H`. With the new coordinate system, `H` will modify the height.
  1922. * `name` is the name of the field as returned in fields to `on_receive_fields`
  1923. * `label`, if not blank, will be text printed on the top left above the field
  1924. * `default` is the default value of the field
  1925. * `default` may contain variable references such as `${text}` which
  1926. will fill the value from the metadata value `text`
  1927. * **Note**: no extra text or more than a single variable is supported ATM.
  1928. * See `field_close_on_enter` to stop enter closing the formspec
  1929. ### `field[<name>;<label>;<default>]`
  1930. * As above, but without position/size units
  1931. * When enter is pressed in field, `fields.key_enter_field` will be sent with
  1932. the name of this field.
  1933. * Special field for creating simple forms, such as sign text input
  1934. * Must be used without a `size[]` element
  1935. * A "Proceed" button will be added automatically
  1936. * See `field_close_on_enter` to stop enter closing the formspec
  1937. ### `field_close_on_enter[<name>;<close_on_enter>]`
  1938. * <name> is the name of the field
  1939. * if <close_on_enter> is false, pressing enter in the field will submit the
  1940. form but not close it.
  1941. * defaults to true when not specified (ie: no tag for a field)
  1942. ### `textarea[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
  1943. * Same as fields above, but with multi-line input
  1944. * If the text overflows, a vertical scrollbar is added.
  1945. * If the name is empty, the textarea is read-only and
  1946. the background is not shown, which corresponds to a multi-line label.
  1947. ### `label[<X>,<Y>;<label>]`
  1948. * The label formspec element displays the text set in `label`
  1949. at the specified position.
  1950. * **Note**: If the new coordinate system is enabled, labels are
  1951. positioned from the center of the text, not the top.
  1952. * The text is displayed directly without automatic line breaking,
  1953. so label should not be used for big text chunks. Newlines can be
  1954. used to make labels multiline.
  1955. * **Note**: With the new coordinate system, newlines are spaced with
  1956. half a coordinate. With the old system, newlines are spaced 2/5 of
  1957. an inventory slot.
  1958. ### `hypertext[<X>,<Y>;<W>,<H>;<name>;<text>]`
  1959. * Displays a static formatted text with hyperlinks.
  1960. * **Note**: This element is currently unstable and subject to change.
  1961. * `x`, `y`, `w` and `h` work as per field
  1962. * `name` is the name of the field as returned in fields to `on_receive_fields` in case of action in text.
  1963. * `text` is the formatted text using `Markup Language` described below.
  1964. ### `vertlabel[<X>,<Y>;<label>]`
  1965. * Textual label drawn vertically
  1966. * `label` is the text on the label
  1967. * **Note**: If the new coordinate system is enabled, vertlabels are
  1968. positioned from the center of the text, not the left.
  1969. ### `button[<X>,<Y>;<W>,<H>;<name>;<label>]`
  1970. * Clickable button. When clicked, fields will be sent.
  1971. * With the old coordinate system, buttons are a set height, but will be vertically
  1972. centred on `H`. With the new coordinate system, `H` will modify the height.
  1973. * `label` is the text on the button
  1974. ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
  1975. * `texture name` is the filename of an image
  1976. * **Note**: Height is supported on both the old and new coordinate systems
  1977. for image_buttons.
  1978. ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]`
  1979. * `texture name` is the filename of an image
  1980. * `noclip=true` means the image button doesn't need to be within specified
  1981. formsize.
  1982. * `drawborder`: draw button border or not
  1983. * `pressed texture name` is the filename of an image on pressed state
  1984. ### `item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]`
  1985. * `item name` is the registered name of an item/node
  1986. * The item description will be used as the tooltip. This can be overridden with
  1987. a tooltip element.
  1988. ### `button_exit[<X>,<Y>;<W>,<H>;<name>;<label>]`
  1989. * When clicked, fields will be sent and the form will quit.
  1990. * Same as `button` in all other respects.
  1991. ### `image_button_exit[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
  1992. * When clicked, fields will be sent and the form will quit.
  1993. * Same as `image_button` in all other respects.
  1994. ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>]`
  1995. * Scrollable item list showing arbitrary text elements
  1996. * `name` fieldname sent to server on doubleclick value is current selected
  1997. element.
  1998. * `listelements` can be prepended by #color in hexadecimal format RRGGBB
  1999. (only).
  2000. * if you want a listelement to start with "#" write "##".
  2001. ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<selected idx>;<transparent>]`
  2002. * Scrollable itemlist showing arbitrary text elements
  2003. * `name` fieldname sent to server on doubleclick value is current selected
  2004. element.
  2005. * `listelements` can be prepended by #RRGGBB (only) in hexadecimal format
  2006. * if you want a listelement to start with "#" write "##"
  2007. * Index to be selected within textlist
  2008. * `true`/`false`: draw transparent background
  2009. * See also `minetest.explode_textlist_event`
  2010. (main menu: `core.explode_textlist_event`).
  2011. ### `tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
  2012. * Show a tab**header** at specific position (ignores formsize)
  2013. * `X` and `Y`: position of the tabheader
  2014. * *Note*: Width and height are automatically chosen with this syntax
  2015. * `name` fieldname data is transferred to Lua
  2016. * `caption 1`...: name shown on top of tab
  2017. * `current_tab`: index of selected tab 1...
  2018. * `transparent` (optional): if true, tabs are semi-transparent
  2019. * `draw_border` (optional): if true, draw a thin line at tab base
  2020. ### `tabheader[<X>,<Y>;<H>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
  2021. * Show a tab**header** at specific position (ignores formsize)
  2022. * **Important note**: This syntax for tabheaders can only be used with the
  2023. new coordinate system.
  2024. * `X` and `Y`: position of the tabheader
  2025. * `H`: height of the tabheader. Width is automatically determined with this syntax.
  2026. * `name` fieldname data is transferred to Lua
  2027. * `caption 1`...: name shown on top of tab
  2028. * `current_tab`: index of selected tab 1...
  2029. * `transparent` (optional): show transparent
  2030. * `draw_border` (optional): draw border
  2031. ### `tabheader[<X>,<Y>;<W>,<H>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
  2032. * Show a tab**header** at specific position (ignores formsize)
  2033. * **Important note**: This syntax for tabheaders can only be used with the
  2034. new coordinate system.
  2035. * `X` and `Y`: position of the tabheader
  2036. * `W` and `H`: width and height of the tabheader
  2037. * `name` fieldname data is transferred to Lua
  2038. * `caption 1`...: name shown on top of tab
  2039. * `current_tab`: index of selected tab 1...
  2040. * `transparent` (optional): show transparent
  2041. * `draw_border` (optional): draw border
  2042. ### `box[<X>,<Y>;<W>,<H>;<color>]`
  2043. * Simple colored box
  2044. * `color` is color specified as a `ColorString`.
  2045. If the alpha component is left blank, the box will be semitransparent.
  2046. If the color is not specified, the box will use the options specified by
  2047. its style. If the color is specified, all styling options will be ignored.
  2048. ### `dropdown[<X>,<Y>;<W>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>;<index event>]`
  2049. * Show a dropdown field
  2050. * **Important note**: There are two different operation modes:
  2051. 1. handle directly on change (only changed dropdown is submitted)
  2052. 2. read the value on pressing a button (all dropdown values are available)
  2053. * `X` and `Y`: position of the dropdown
  2054. * `W`: width of the dropdown. Height is automatically chosen with this syntax.
  2055. * Fieldname data is transferred to Lua
  2056. * Items to be shown in dropdown
  2057. * Index of currently selected dropdown item
  2058. * `index event` (optional, allowed parameter since formspec version 4): Specifies the
  2059. event field value for selected items.
  2060. * `true`: Selected item index
  2061. * `false` (default): Selected item value
  2062. ### `dropdown[<X>,<Y>;<W>,<H>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>;<index event>]`
  2063. * Show a dropdown field
  2064. * **Important note**: This syntax for dropdowns can only be used with the
  2065. new coordinate system.
  2066. * **Important note**: There are two different operation modes:
  2067. 1. handle directly on change (only changed dropdown is submitted)
  2068. 2. read the value on pressing a button (all dropdown values are available)
  2069. * `X` and `Y`: position of the dropdown
  2070. * `W` and `H`: width and height of the dropdown
  2071. * Fieldname data is transferred to Lua
  2072. * Items to be shown in dropdown
  2073. * Index of currently selected dropdown item
  2074. * `index event` (optional, allowed parameter since formspec version 4): Specifies the
  2075. event field value for selected items.
  2076. * `true`: Selected item index
  2077. * `false` (default): Selected item value
  2078. ### `checkbox[<X>,<Y>;<name>;<label>;<selected>]`
  2079. * Show a checkbox
  2080. * `name` fieldname data is transferred to Lua
  2081. * `label` to be shown left of checkbox
  2082. * `selected` (optional): `true`/`false`
  2083. * **Note**: If the new coordinate system is enabled, checkboxes are
  2084. positioned from the center of the checkbox, not the top.
  2085. ### `scrollbar[<X>,<Y>;<W>,<H>;<orientation>;<name>;<value>]`
  2086. * Show a scrollbar using options defined by the previous `scrollbaroptions[]`
  2087. * There are two ways to use it:
  2088. 1. handle the changed event (only changed scrollbar is available)
  2089. 2. read the value on pressing a button (all scrollbars are available)
  2090. * `orientation`: `vertical`/`horizontal`. Default horizontal.
  2091. * Fieldname data is transferred to Lua
  2092. * Value of this trackbar is set to (`0`-`1000`) by default
  2093. * See also `minetest.explode_scrollbar_event`
  2094. (main menu: `core.explode_scrollbar_event`).
  2095. ### `scrollbaroptions[opt1;opt2;...]`
  2096. * Sets options for all following `scrollbar[]` elements
  2097. * `min=<int>`
  2098. * Sets scrollbar minimum value, defaults to `0`.
  2099. * `max=<int>`
  2100. * Sets scrollbar maximum value, defaults to `1000`.
  2101. If the max is equal to the min, the scrollbar will be disabled.
  2102. * `smallstep=<int>`
  2103. * Sets scrollbar step value when the arrows are clicked or the mouse wheel is
  2104. scrolled.
  2105. * If this is set to a negative number, the value will be reset to `10`.
  2106. * `largestep=<int>`
  2107. * Sets scrollbar step value used by page up and page down.
  2108. * If this is set to a negative number, the value will be reset to `100`.
  2109. * `thumbsize=<int>`
  2110. * Sets size of the thumb on the scrollbar. Size is calculated in the number of
  2111. units the thumb spans out of the range of the scrollbar values.
  2112. * Example: If a scrollbar has a `min` of 1 and a `max` of 100, a thumbsize of 10
  2113. would span a tenth of the scrollbar space.
  2114. * If this is set to zero or less, the value will be reset to `1`.
  2115. * `arrows=<show/hide/default>`
  2116. * Whether to show the arrow buttons on the scrollbar. `default` hides the arrows
  2117. when the scrollbar gets too small, but shows them otherwise.
  2118. ### `table[<X>,<Y>;<W>,<H>;<name>;<cell 1>,<cell 2>,...,<cell n>;<selected idx>]`
  2119. * Show scrollable table using options defined by the previous `tableoptions[]`
  2120. * Displays cells as defined by the previous `tablecolumns[]`
  2121. * `name`: fieldname sent to server on row select or doubleclick
  2122. * `cell 1`...`cell n`: cell contents given in row-major order
  2123. * `selected idx`: index of row to be selected within table (first row = `1`)
  2124. * See also `minetest.explode_table_event`
  2125. (main menu: `core.explode_table_event`).
  2126. ### `tableoptions[<opt 1>;<opt 2>;...]`
  2127. * Sets options for `table[]`
  2128. * `color=#RRGGBB`
  2129. * default text color (`ColorString`), defaults to `#FFFFFF`
  2130. * `background=#RRGGBB`
  2131. * table background color (`ColorString`), defaults to `#000000`
  2132. * `border=<true/false>`
  2133. * should the table be drawn with a border? (default: `true`)
  2134. * `highlight=#RRGGBB`
  2135. * highlight background color (`ColorString`), defaults to `#466432`
  2136. * `highlight_text=#RRGGBB`
  2137. * highlight text color (`ColorString`), defaults to `#FFFFFF`
  2138. * `opendepth=<value>`
  2139. * all subtrees up to `depth < value` are open (default value = `0`)
  2140. * only useful when there is a column of type "tree"
  2141. ### `tablecolumns[<type 1>,<opt 1a>,<opt 1b>,...;<type 2>,<opt 2a>,<opt 2b>;...]`
  2142. * Sets columns for `table[]`
  2143. * Types: `text`, `image`, `color`, `indent`, `tree`
  2144. * `text`: show cell contents as text
  2145. * `image`: cell contents are an image index, use column options to define
  2146. images.
  2147. * `color`: cell contents are a ColorString and define color of following
  2148. cell.
  2149. * `indent`: cell contents are a number and define indentation of following
  2150. cell.
  2151. * `tree`: same as indent, but user can open and close subtrees
  2152. (treeview-like).
  2153. * Column options:
  2154. * `align=<value>`
  2155. * for `text` and `image`: content alignment within cells.
  2156. Available values: `left` (default), `center`, `right`, `inline`
  2157. * `width=<value>`
  2158. * for `text` and `image`: minimum width in em (default: `0`)
  2159. * for `indent` and `tree`: indent width in em (default: `1.5`)
  2160. * `padding=<value>`: padding left of the column, in em (default `0.5`).
  2161. Exception: defaults to 0 for indent columns
  2162. * `tooltip=<value>`: tooltip text (default: empty)
  2163. * `image` column options:
  2164. * `0=<value>` sets image for image index 0
  2165. * `1=<value>` sets image for image index 1
  2166. * `2=<value>` sets image for image index 2
  2167. * and so on; defined indices need not be contiguous empty or
  2168. non-numeric cells are treated as `0`.
  2169. * `color` column options:
  2170. * `span=<value>`: number of following columns to affect
  2171. (default: infinite).
  2172. ### `style[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
  2173. * Set the style for the element(s) matching `selector` by name.
  2174. * `selector` can be one of:
  2175. * `<name>` - An element name. Includes `*`, which represents every element.
  2176. * `<name>:<state>` - An element name, a colon, and one or more states.
  2177. * `state` is a list of states separated by the `+` character.
  2178. * If a state is provided, the style will only take effect when the element is in that state.
  2179. * All provided states must be active for the style to apply.
  2180. * Note: this **must** be before the element is defined.
  2181. * See [Styling Formspecs].
  2182. ### `style_type[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
  2183. * Set the style for the element(s) matching `selector` by type.
  2184. * `selector` can be one of:
  2185. * `<type>` - An element type. Includes `*`, which represents every element.
  2186. * `<type>:<state>` - An element type, a colon, and one or more states.
  2187. * `state` is a list of states separated by the `+` character.
  2188. * If a state is provided, the style will only take effect when the element is in that state.
  2189. * All provided states must be active for the style to apply.
  2190. * See [Styling Formspecs].
  2191. ### `set_focus[<name>;<force>]`
  2192. * Sets the focus to the element with the same `name` parameter.
  2193. * **Note**: This element must be placed before the element it focuses.
  2194. * `force` (optional, default `false`): By default, focus is not applied for
  2195. re-sent formspecs with the same name so that player-set focus is kept.
  2196. `true` sets the focus to the specified element for every sent formspec.
  2197. * The following elements have the ability to be focused:
  2198. * checkbox
  2199. * button
  2200. * button_exit
  2201. * image_button
  2202. * image_button_exit
  2203. * item_image_button
  2204. * table
  2205. * textlist
  2206. * dropdown
  2207. * field
  2208. * pwdfield
  2209. * textarea
  2210. * scrollbar
  2211. Migrating to Real Coordinates
  2212. -----------------------------
  2213. In the old system, positions included padding and spacing. Padding is a gap between
  2214. the formspec window edges and content, and spacing is the gaps between items. For
  2215. example, two `1x1` elements at `0,0` and `1,1` would have a spacing of `5/4` between them,
  2216. and a padding of `3/8` from the formspec edge. It may be easiest to recreate old layouts
  2217. in the new coordinate system from scratch.
  2218. To recreate an old layout with padding, you'll need to pass the positions and sizes
  2219. through the following formula to re-introduce padding:
  2220. ```
  2221. pos = (oldpos + 1)*spacing + padding
  2222. where
  2223. padding = 3/8
  2224. spacing = 5/4
  2225. ```
  2226. You'll need to change the `size[]` tag like this:
  2227. ```
  2228. size = (oldsize-1)*spacing + padding*2 + 1
  2229. ```
  2230. A few elements had random offsets in the old system. Here is a table which shows these
  2231. offsets when migrating:
  2232. | Element | Position | Size | Notes
  2233. |---------|------------|---------|-------
  2234. | box | +0.3, +0.1 | 0, -0.4 |
  2235. | button | | | Buttons now support height, so set h = 2 * 15/13 * 0.35, and reposition if h ~= 15/13 * 0.35 before
  2236. | list | | | Spacing is now 0.25 for both directions, meaning lists will be taller in height
  2237. | label | 0, +0.3 | | The first line of text is now positioned centered exactly at the position specified
  2238. Styling Formspecs
  2239. -----------------
  2240. Formspec elements can be themed using the style elements:
  2241. style[<name 1>,<name 2>,...;<prop1>;<prop2>;...]
  2242. style[<name 1>:<state>,<name 2>:<state>,...;<prop1>;<prop2>;...]
  2243. style_type[<type 1>,<type 2>,...;<prop1>;<prop2>;...]
  2244. style_type[<type 1>:<state>,<type 2>:<state>,...;<prop1>;<prop2>;...]
  2245. Where a prop is:
  2246. property_name=property_value
  2247. For example:
  2248. style_type[button;bgcolor=#006699]
  2249. style[world_delete;bgcolor=red;textcolor=yellow]
  2250. button[4,3.95;2.6,1;world_delete;Delete]
  2251. A name/type can optionally be a comma separated list of names/types, like so:
  2252. world_delete,world_create,world_configure
  2253. button,image_button
  2254. A `*` type can be used to select every element in the formspec.
  2255. Any name/type in the list can also be accompanied by a `+`-separated list of states, like so:
  2256. world_delete:hovered+pressed
  2257. button:pressed
  2258. States allow you to apply styles in response to changes in the element, instead of applying at all times.
  2259. Setting a property to nothing will reset it to the default value. For example:
  2260. style_type[button;bgimg=button.png;bgimg_pressed=button_pressed.png;border=false]
  2261. style[btn_exit;bgimg=;bgimg_pressed=;border=;bgcolor=red]
  2262. ### Supported Element Types
  2263. Some types may inherit styles from parent types.
  2264. * animated_image, inherits from image
  2265. * box
  2266. * button
  2267. * button_exit, inherits from button
  2268. * checkbox
  2269. * dropdown
  2270. * field
  2271. * image
  2272. * image_button
  2273. * item_image_button
  2274. * label
  2275. * list
  2276. * model
  2277. * pwdfield, inherits from field
  2278. * scrollbar
  2279. * tabheader
  2280. * table
  2281. * textarea
  2282. * textlist
  2283. * vertlabel, inherits from label
  2284. ### Valid Properties
  2285. * animated_image
  2286. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2287. * box
  2288. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2289. * Defaults to false in formspec_version version 3 or higher
  2290. * **Note**: `colors`, `bordercolors`, and `borderwidths` accept multiple input types:
  2291. * Single value (e.g. `#FF0`): All corners/borders.
  2292. * Two values (e.g. `red,#FFAAFF`): top-left and bottom-right,top-right and bottom-left/
  2293. top and bottom,left and right.
  2294. * Four values (e.g. `blue,#A0F,green,#FFFA`): top-left/top and rotates clockwise.
  2295. * These work similarly to CSS borders.
  2296. * colors - `ColorString`. Sets the color(s) of the box corners. Default `black`.
  2297. * bordercolors - `ColorString`. Sets the color(s) of the borders. Default `black`.
  2298. * borderwidths - Integer. Sets the width(s) of the borders in pixels. If the width is
  2299. negative, the border will extend inside the box, whereas positive extends outside
  2300. the box. A width of zero results in no border; this is default.
  2301. * button, button_exit, image_button, item_image_button
  2302. * alpha - boolean, whether to draw alpha in bgimg. Default true.
  2303. * bgcolor - color, sets button tint.
  2304. * bgcolor_hovered - color when hovered. Defaults to a lighter bgcolor when not provided.
  2305. * This is deprecated, use states instead.
  2306. * bgcolor_pressed - color when pressed. Defaults to a darker bgcolor when not provided.
  2307. * This is deprecated, use states instead.
  2308. * bgimg - standard background image. Defaults to none.
  2309. * bgimg_hovered - background image when hovered. Defaults to bgimg when not provided.
  2310. * This is deprecated, use states instead.
  2311. * bgimg_middle - Makes the bgimg textures render in 9-sliced mode and defines the middle rect.
  2312. See background9[] documentation for more details. This property also pads the
  2313. button's content when set.
  2314. * bgimg_pressed - background image when pressed. Defaults to bgimg when not provided.
  2315. * This is deprecated, use states instead.
  2316. * font - Sets font type. This is a comma separated list of options. Valid options:
  2317. * Main font type options. These cannot be combined with each other:
  2318. * `normal`: Default font
  2319. * `mono`: Monospaced font
  2320. * Font modification options. If used without a main font type, `normal` is used:
  2321. * `bold`: Makes font bold.
  2322. * `italic`: Makes font italic.
  2323. Default `normal`.
  2324. * font_size - Sets font size. Default is user-set. Can have multiple values:
  2325. * `<number>`: Sets absolute font size to `number`.
  2326. * `+<number>`/`-<number>`: Offsets default font size by `number` points.
  2327. * `*<number>`: Multiplies default font size by `number`, similar to CSS `em`.
  2328. * border - boolean, draw border. Set to false to hide the bevelled button pane. Default true.
  2329. * content_offset - 2d vector, shifts the position of the button's content without resizing it.
  2330. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2331. * padding - rect, adds space between the edges of the button and the content. This value is
  2332. relative to bgimg_middle.
  2333. * sound - a sound to be played when triggered.
  2334. * textcolor - color, default white.
  2335. * checkbox
  2336. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2337. * sound - a sound to be played when triggered.
  2338. * dropdown
  2339. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2340. * sound - a sound to be played when the entry is changed.
  2341. * field, pwdfield, textarea
  2342. * border - set to false to hide the textbox background and border. Default true.
  2343. * font - Sets font type. See button `font` property for more information.
  2344. * font_size - Sets font size. See button `font_size` property for more information.
  2345. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2346. * textcolor - color. Default white.
  2347. * model
  2348. * bgcolor - color, sets background color.
  2349. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2350. * Default to false in formspec_version version 3 or higher
  2351. * image
  2352. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2353. * Default to false in formspec_version version 3 or higher
  2354. * item_image
  2355. * noclip - boolean, set to true to allow the element to exceed formspec bounds. Default to false.
  2356. * label, vertlabel
  2357. * font - Sets font type. See button `font` property for more information.
  2358. * font_size - Sets font size. See button `font_size` property for more information.
  2359. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2360. * list
  2361. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2362. * size - 2d vector, sets the size of inventory slots in coordinates.
  2363. * spacing - 2d vector, sets the space between inventory slots in coordinates.
  2364. * image_button (additional properties)
  2365. * fgimg - standard image. Defaults to none.
  2366. * fgimg_hovered - image when hovered. Defaults to fgimg when not provided.
  2367. * This is deprecated, use states instead.
  2368. * fgimg_pressed - image when pressed. Defaults to fgimg when not provided.
  2369. * This is deprecated, use states instead.
  2370. * fgimg_middle - Makes the fgimg textures render in 9-sliced mode and defines the middle rect.
  2371. See background9[] documentation for more details.
  2372. * NOTE: The parameters of any given image_button will take precedence over fgimg/fgimg_pressed
  2373. * sound - a sound to be played when triggered.
  2374. * scrollbar
  2375. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2376. * tabheader
  2377. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2378. * sound - a sound to be played when a different tab is selected.
  2379. * textcolor - color. Default white.
  2380. * table, textlist
  2381. * font - Sets font type. See button `font` property for more information.
  2382. * font_size - Sets font size. See button `font_size` property for more information.
  2383. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2384. ### Valid States
  2385. * *all elements*
  2386. * default - Equivalent to providing no states
  2387. * button, button_exit, image_button, item_image_button
  2388. * hovered - Active when the mouse is hovering over the element
  2389. * pressed - Active when the button is pressed
  2390. Markup Language
  2391. ---------------
  2392. Markup language used in `hypertext[]` elements uses tags that look like HTML tags.
  2393. The markup language is currently unstable and subject to change. Use with caution.
  2394. Some tags can enclose text, they open with `<tagname>` and close with `</tagname>`.
  2395. Tags can have attributes, in that case, attributes are in the opening tag in
  2396. form of a key/value separated with equal signs. Attribute values should not be quoted.
  2397. If you want to insert a literal greater-than sign or a backslash into the text,
  2398. you must escape it by preceding it with a backslash.
  2399. These are the technically basic tags but see below for usual tags. Base tags are:
  2400. `<style color=... font=... size=...>...</style>`
  2401. Changes the style of the text.
  2402. * `color`: Text color. Given color is a `colorspec`.
  2403. * `size`: Text size.
  2404. * `font`: Text font (`mono` or `normal`).
  2405. `<global background=... margin=... valign=... color=... hovercolor=... size=... font=... halign=... >`
  2406. Sets global style.
  2407. Global only styles:
  2408. * `background`: Text background, a `colorspec` or `none`.
  2409. * `margin`: Page margins in pixel.
  2410. * `valign`: Text vertical alignment (`top`, `middle`, `bottom`).
  2411. Inheriting styles (affects child elements):
  2412. * `color`: Default text color. Given color is a `colorspec`.
  2413. * `hovercolor`: Color of <action> tags when mouse is over.
  2414. * `size`: Default text size.
  2415. * `font`: Default text font (`mono` or `normal`).
  2416. * `halign`: Default text horizontal alignment (`left`, `right`, `center`, `justify`).
  2417. This tag needs to be placed only once as it changes the global settings of the
  2418. text. Anyway, if several tags are placed, each changed will be made in the order
  2419. tags appear.
  2420. `<tag name=... color=... hovercolor=... font=... size=...>`
  2421. Defines or redefines tag style. This can be used to define new tags.
  2422. * `name`: Name of the tag to define or change.
  2423. * `color`: Text color. Given color is a `colorspec`.
  2424. * `hovercolor`: Text color when element hovered (only for `action` tags). Given color is a `colorspec`.
  2425. * `size`: Text size.
  2426. * `font`: Text font (`mono` or `normal`).
  2427. Following tags are the usual tags for text layout. They are defined by default.
  2428. Other tags can be added using `<tag ...>` tag.
  2429. `<normal>...</normal>`: Normal size text
  2430. `<big>...</big>`: Big text
  2431. `<bigger>...</bigger>`: Bigger text
  2432. `<center>...</center>`: Centered text
  2433. `<left>...</left>`: Left-aligned text
  2434. `<right>...</right>`: Right-aligned text
  2435. `<justify>...</justify>`: Justified text
  2436. `<mono>...</mono>`: Monospaced font
  2437. `<b>...</b>`, `<i>...</i>`, `<u>...</u>`: Bold, italic, underline styles.
  2438. `<action name=...>...</action>`
  2439. Make that text a clickable text triggering an action.
  2440. * `name`: Name of the action (mandatory).
  2441. When clicked, the formspec is send to the server. The value of the text field
  2442. sent to `on_player_receive_fields` will be "action:" concatenated to the action
  2443. name.
  2444. `<img name=... float=... width=... height=...>`
  2445. Draws an image which is present in the client media cache.
  2446. * `name`: Name of the texture (mandatory).
  2447. * `float`: If present, makes the image floating (`left` or `right`).
  2448. * `width`: Force image width instead of taking texture width.
  2449. * `height`: Force image height instead of taking texture height.
  2450. If only width or height given, texture aspect is kept.
  2451. `<item name=... float=... width=... height=... rotate=...>`
  2452. Draws an item image.
  2453. * `name`: Item string of the item to draw (mandatory).
  2454. * `float`: If present, makes the image floating (`left` or `right`).
  2455. * `width`: Item image width.
  2456. * `height`: Item image height.
  2457. * `rotate`: Rotate item image if set to `yes` or `X,Y,Z`. X, Y and Z being
  2458. rotation speeds in percent of standard speed (-1000 to 1000). Works only if
  2459. `inventory_items_animations` is set to true.
  2460. * `angle`: Angle in which the item image is shown. Value has `X,Y,Z` form.
  2461. X, Y and Z being angles around each three axes. Works only if
  2462. `inventory_items_animations` is set to true.
  2463. Inventory
  2464. =========
  2465. Inventory locations
  2466. -------------------
  2467. * `"context"`: Selected node metadata (deprecated: `"current_name"`)
  2468. * `"current_player"`: Player to whom the menu is shown
  2469. * `"player:<name>"`: Any player
  2470. * `"nodemeta:<X>,<Y>,<Z>"`: Any node metadata
  2471. * `"detached:<name>"`: A detached inventory
  2472. Player Inventory lists
  2473. ----------------------
  2474. * `main`: list containing the default inventory
  2475. * `craft`: list containing the craft input
  2476. * `craftpreview`: list containing the craft prediction
  2477. * `craftresult`: list containing the crafted output
  2478. * `hand`: list containing an override for the empty hand
  2479. * Is not created automatically, use `InvRef:set_size`
  2480. * Is only used to enhance the empty hand's tool capabilities
  2481. Colors
  2482. ======
  2483. `ColorString`
  2484. -------------
  2485. `#RGB` defines a color in hexadecimal format.
  2486. `#RGBA` defines a color in hexadecimal format and alpha channel.
  2487. `#RRGGBB` defines a color in hexadecimal format.
  2488. `#RRGGBBAA` defines a color in hexadecimal format and alpha channel.
  2489. Named colors are also supported and are equivalent to
  2490. [CSS Color Module Level 4](https://www.w3.org/TR/css-color-4/#named-color).
  2491. To specify the value of the alpha channel, append `#A` or `#AA` to the end of
  2492. the color name (e.g. `colorname#08`).
  2493. `ColorSpec`
  2494. -----------
  2495. A ColorSpec specifies a 32-bit color. It can be written in any of the following
  2496. forms:
  2497. * table form: Each element ranging from 0..255 (a, if absent, defaults to 255):
  2498. * `colorspec = {a=255, r=0, g=255, b=0}`
  2499. * numerical form: The raw integer value of an ARGB8 quad:
  2500. * `colorspec = 0xFF00FF00`
  2501. * string form: A ColorString (defined above):
  2502. * `colorspec = "green"`
  2503. Escape sequences
  2504. ================
  2505. Most text can contain escape sequences, that can for example color the text.
  2506. There are a few exceptions: tab headers, dropdowns and vertical labels can't.
  2507. The following functions provide escape sequences:
  2508. * `minetest.get_color_escape_sequence(color)`:
  2509. * `color` is a ColorString
  2510. * The escape sequence sets the text color to `color`
  2511. * `minetest.colorize(color, message)`:
  2512. * Equivalent to:
  2513. `minetest.get_color_escape_sequence(color) ..
  2514. message ..
  2515. minetest.get_color_escape_sequence("#ffffff")`
  2516. * `minetest.get_background_escape_sequence(color)`
  2517. * `color` is a ColorString
  2518. * The escape sequence sets the background of the whole text element to
  2519. `color`. Only defined for item descriptions and tooltips.
  2520. * `minetest.strip_foreground_colors(str)`
  2521. * Removes foreground colors added by `get_color_escape_sequence`.
  2522. * `minetest.strip_background_colors(str)`
  2523. * Removes background colors added by `get_background_escape_sequence`.
  2524. * `minetest.strip_colors(str)`
  2525. * Removes all color escape sequences.
  2526. Spatial Vectors
  2527. ===============
  2528. Minetest stores 3-dimensional spatial vectors in Lua as tables of 3 coordinates,
  2529. and has a class to represent them (`vector.*`), which this chapter is about.
  2530. For details on what a spatial vectors is, please refer to Wikipedia:
  2531. https://en.wikipedia.org/wiki/Euclidean_vector.
  2532. Spatial vectors are used for various things, including, but not limited to:
  2533. * any 3D spatial vector (x/y/z-directions)
  2534. * Euler angles (pitch/yaw/roll in radians) (Spatial vectors have no real semantic
  2535. meaning here. Therefore, most vector operations make no sense in this use case.)
  2536. Note that they are *not* used for:
  2537. * n-dimensional vectors where n is not 3 (ie. n=2)
  2538. * arrays of the form `{num, num, num}`
  2539. The API documentation may refer to spatial vectors, as produced by `vector.new`,
  2540. by any of the following notations:
  2541. * `(x, y, z)` (Used rarely, and only if it's clear that it's a vector.)
  2542. * `vector.new(x, y, z)`
  2543. * `{x=num, y=num, z=num}` (Even here you are still supposed to use `vector.new`.)
  2544. Compatibility notes
  2545. -------------------
  2546. Vectors used to be defined as tables of the form `{x = num, y = num, z = num}`.
  2547. Since Minetest 5.5.0, vectors additionally have a metatable to enable easier use.
  2548. Note: Those old-style vectors can still be found in old mod code. Hence, mod and
  2549. engine APIs still need to be able to cope with them in many places.
  2550. Manually constructed tables are deprecated and highly discouraged. This interface
  2551. should be used to ensure seamless compatibility between mods and the Minetest API.
  2552. This is especially important to callback function parameters and functions overwritten
  2553. by mods.
  2554. Also, though not likely, the internal implementation of a vector might change in
  2555. the future.
  2556. In your own code, or if you define your own API, you can, of course, still use
  2557. other representations of vectors.
  2558. Vectors provided by API functions will provide an instance of this class if not
  2559. stated otherwise. Mods should adapt this for convenience reasons.
  2560. Special properties of the class
  2561. -------------------------------
  2562. Vectors can be indexed with numbers and allow method and operator syntax.
  2563. All these forms of addressing a vector `v` are valid:
  2564. `v[1]`, `v[3]`, `v.x`, `v[1] = 42`, `v.y = 13`
  2565. Note: Prefer letter over number indexing for performance and compatibility reasons.
  2566. Where `v` is a vector and `foo` stands for any function name, `v:foo(...)` does
  2567. the same as `vector.foo(v, ...)`, apart from deprecated functionality.
  2568. `tostring` is defined for vectors, see `vector.to_string`.
  2569. The metatable that is used for vectors can be accessed via `vector.metatable`.
  2570. Do not modify it!
  2571. All `vector.*` functions allow vectors `{x = X, y = Y, z = Z}` without metatables.
  2572. Returned vectors always have a metatable set.
  2573. Common functions and methods
  2574. ----------------------------
  2575. For the following functions (and subchapters),
  2576. `v`, `v1`, `v2` are vectors,
  2577. `p1`, `p2` are position vectors,
  2578. `s` is a scalar (a number),
  2579. vectors are written like this: `(x, y, z)`:
  2580. * `vector.new([a[, b, c]])`:
  2581. * Returns a new vector `(a, b, c)`.
  2582. * Deprecated: `vector.new()` does the same as `vector.zero()` and
  2583. `vector.new(v)` does the same as `vector.copy(v)`
  2584. * `vector.zero()`:
  2585. * Returns a new vector `(0, 0, 0)`.
  2586. * `vector.copy(v)`:
  2587. * Returns a copy of the vector `v`.
  2588. * `vector.from_string(s[, init])`:
  2589. * Returns `v, np`, where `v` is a vector read from the given string `s` and
  2590. `np` is the next position in the string after the vector.
  2591. * Returns `nil` on failure.
  2592. * `s`: Has to begin with a substring of the form `"(x, y, z)"`. Additional
  2593. spaces, leaving away commas and adding an additional comma to the end
  2594. is allowed.
  2595. * `init`: If given starts looking for the vector at this string index.
  2596. * `vector.to_string(v)`:
  2597. * Returns a string of the form `"(x, y, z)"`.
  2598. * `tostring(v)` does the same.
  2599. * `vector.direction(p1, p2)`:
  2600. * Returns a vector of length 1 with direction `p1` to `p2`.
  2601. * If `p1` and `p2` are identical, returns `(0, 0, 0)`.
  2602. * `vector.distance(p1, p2)`:
  2603. * Returns zero or a positive number, the distance between `p1` and `p2`.
  2604. * `vector.length(v)`:
  2605. * Returns zero or a positive number, the length of vector `v`.
  2606. * `vector.normalize(v)`:
  2607. * Returns a vector of length 1 with direction of vector `v`.
  2608. * If `v` has zero length, returns `(0, 0, 0)`.
  2609. * `vector.floor(v)`:
  2610. * Returns a vector, each dimension rounded down.
  2611. * `vector.round(v)`:
  2612. * Returns a vector, each dimension rounded to nearest integer.
  2613. * At a multiple of 0.5, rounds away from zero.
  2614. * `vector.apply(v, func)`:
  2615. * Returns a vector where the function `func` has been applied to each
  2616. component.
  2617. * `vector.combine(v, w, func)`:
  2618. * Returns a vector where the function `func` has combined both components of `v` and `w`
  2619. for each component
  2620. * `vector.equals(v1, v2)`:
  2621. * Returns a boolean, `true` if the vectors are identical.
  2622. * `vector.sort(v1, v2)`:
  2623. * Returns in order minp, maxp vectors of the cuboid defined by `v1`, `v2`.
  2624. * `vector.angle(v1, v2)`:
  2625. * Returns the angle between `v1` and `v2` in radians.
  2626. * `vector.dot(v1, v2)`:
  2627. * Returns the dot product of `v1` and `v2`.
  2628. * `vector.cross(v1, v2)`:
  2629. * Returns the cross product of `v1` and `v2`.
  2630. * `vector.offset(v, x, y, z)`:
  2631. * Returns the sum of the vectors `v` and `(x, y, z)`.
  2632. * `vector.check(v)`:
  2633. * Returns a boolean value indicating whether `v` is a real vector, eg. created
  2634. by a `vector.*` function.
  2635. * Returns `false` for anything else, including tables like `{x=3,y=1,z=4}`.
  2636. For the following functions `x` can be either a vector or a number:
  2637. * `vector.add(v, x)`:
  2638. * Returns a vector.
  2639. * If `x` is a vector: Returns the sum of `v` and `x`.
  2640. * If `x` is a number: Adds `x` to each component of `v`.
  2641. * `vector.subtract(v, x)`:
  2642. * Returns a vector.
  2643. * If `x` is a vector: Returns the difference of `v` subtracted by `x`.
  2644. * If `x` is a number: Subtracts `x` from each component of `v`.
  2645. * `vector.multiply(v, s)`:
  2646. * Returns a scaled vector.
  2647. * Deprecated: If `s` is a vector: Returns the Schur product.
  2648. * `vector.divide(v, s)`:
  2649. * Returns a scaled vector.
  2650. * Deprecated: If `s` is a vector: Returns the Schur quotient.
  2651. Operators
  2652. ---------
  2653. Operators can be used if all of the involved vectors have metatables:
  2654. * `v1 == v2`:
  2655. * Returns whether `v1` and `v2` are identical.
  2656. * `-v`:
  2657. * Returns the additive inverse of v.
  2658. * `v1 + v2`:
  2659. * Returns the sum of both vectors.
  2660. * Note: `+` can not be used together with scalars.
  2661. * `v1 - v2`:
  2662. * Returns the difference of `v1` subtracted by `v2`.
  2663. * Note: `-` can not be used together with scalars.
  2664. * `v * s` or `s * v`:
  2665. * Returns `v` scaled by `s`.
  2666. * `v / s`:
  2667. * Returns `v` scaled by `1 / s`.
  2668. Rotation-related functions
  2669. --------------------------
  2670. For the following functions `a` is an angle in radians and `r` is a rotation
  2671. vector (`{x = <pitch>, y = <yaw>, z = <roll>}`) where pitch, yaw and roll are
  2672. angles in radians.
  2673. * `vector.rotate(v, r)`:
  2674. * Applies the rotation `r` to `v` and returns the result.
  2675. * `vector.rotate(vector.new(0, 0, 1), r)` and
  2676. `vector.rotate(vector.new(0, 1, 0), r)` return vectors pointing
  2677. forward and up relative to an entity's rotation `r`.
  2678. * `vector.rotate_around_axis(v1, v2, a)`:
  2679. * Returns `v1` rotated around axis `v2` by `a` radians according to
  2680. the right hand rule.
  2681. * `vector.dir_to_rotation(direction[, up])`:
  2682. * Returns a rotation vector for `direction` pointing forward using `up`
  2683. as the up vector.
  2684. * If `up` is omitted, the roll of the returned vector defaults to zero.
  2685. * Otherwise `direction` and `up` need to be vectors in a 90 degree angle to each other.
  2686. Further helpers
  2687. ---------------
  2688. There are more helper functions involving vectors, but they are listed elsewhere
  2689. because they only work on specific sorts of vectors or involve things that are not
  2690. vectors.
  2691. For example:
  2692. * `minetest.hash_node_position` (Only works on node positions.)
  2693. * `minetest.dir_to_wallmounted` (Involves wallmounted param2 values.)
  2694. Helper functions
  2695. ================
  2696. * `dump2(obj, name, dumped)`: returns a string which makes `obj`
  2697. human-readable, handles reference loops.
  2698. * `obj`: arbitrary variable
  2699. * `name`: string, default: `"_"`
  2700. * `dumped`: table, default: `{}`
  2701. * `dump(obj, dumped)`: returns a string which makes `obj` human-readable
  2702. * `obj`: arbitrary variable
  2703. * `dumped`: table, default: `{}`
  2704. * `math.hypot(x, y)`
  2705. * Get the hypotenuse of a triangle with legs x and y.
  2706. Useful for distance calculation.
  2707. * `math.sign(x, tolerance)`: returns `-1`, `0` or `1`
  2708. * Get the sign of a number.
  2709. * tolerance: number, default: `0.0`
  2710. * If the absolute value of `x` is within the `tolerance` or `x` is NaN,
  2711. `0` is returned.
  2712. * `math.factorial(x)`: returns the factorial of `x`
  2713. * `math.round(x)`: Returns `x` rounded to the nearest integer.
  2714. * At a multiple of 0.5, rounds away from zero.
  2715. * `string.split(str, separator, include_empty, max_splits, sep_is_pattern)`
  2716. * `separator`: string, default: `","`
  2717. * `include_empty`: boolean, default: `false`
  2718. * `max_splits`: number, if it's negative, splits aren't limited,
  2719. default: `-1`
  2720. * `sep_is_pattern`: boolean, it specifies whether separator is a plain
  2721. string or a pattern (regex), default: `false`
  2722. * e.g. `"a,b":split","` returns `{"a","b"}`
  2723. * `string:trim()`: returns the string without whitespace pre- and suffixes
  2724. * e.g. `"\n \t\tfoo bar\t ":trim()` returns `"foo bar"`
  2725. * `minetest.wrap_text(str, limit, as_table)`: returns a string or table
  2726. * Adds newlines to the string to keep it within the specified character
  2727. limit
  2728. * Note that the returned lines may be longer than the limit since it only
  2729. splits at word borders.
  2730. * `limit`: number, maximal amount of characters in one line
  2731. * `as_table`: boolean, if set to true, a table of lines instead of a string
  2732. is returned, default: `false`
  2733. * `minetest.pos_to_string(pos, decimal_places)`: returns string `"(X,Y,Z)"`
  2734. * `pos`: table {x=X, y=Y, z=Z}
  2735. * Converts the position `pos` to a human-readable, printable string
  2736. * `decimal_places`: number, if specified, the x, y and z values of
  2737. the position are rounded to the given decimal place.
  2738. * `minetest.string_to_pos(string)`: returns a position or `nil`
  2739. * Same but in reverse.
  2740. * If the string can't be parsed to a position, nothing is returned.
  2741. * `minetest.string_to_area("(X1, Y1, Z1) (X2, Y2, Z2)", relative_to)`:
  2742. * returns two positions
  2743. * Converts a string representing an area box into two positions
  2744. * X1, Y1, ... Z2 are coordinates
  2745. * `relative_to`: Optional. If set to a position, each coordinate
  2746. can use the tilde notation for relative positions
  2747. * Tilde notation: "~": Relative coordinate
  2748. "~<number>": Relative coordinate plus <number>
  2749. * Example: `minetest.string_to_area("(1,2,3) (~5,~-5,~)", {x=10,y=10,z=10})`
  2750. returns `{x=1,y=2,z=3}, {x=15,y=5,z=10}`
  2751. * `minetest.formspec_escape(string)`: returns a string
  2752. * escapes the characters "[", "]", "\", "," and ";", which can not be used
  2753. in formspecs.
  2754. * `minetest.is_yes(arg)`
  2755. * returns true if passed 'y', 'yes', 'true' or a number that isn't zero.
  2756. * `minetest.is_nan(arg)`
  2757. * returns true when the passed number represents NaN.
  2758. * `minetest.get_us_time()`
  2759. * returns time with microsecond precision. May not return wall time.
  2760. * `table.copy(table)`: returns a table
  2761. * returns a deep copy of `table`
  2762. * `table.indexof(list, val)`: returns the smallest numerical index containing
  2763. the value `val` in the table `list`. Non-numerical indices are ignored.
  2764. If `val` could not be found, `-1` is returned. `list` must not have
  2765. negative indices.
  2766. * `table.insert_all(table, other_table)`:
  2767. * Appends all values in `other_table` to `table` - uses `#table + 1` to
  2768. find new indices.
  2769. * `table.key_value_swap(t)`: returns a table with keys and values swapped
  2770. * If multiple keys in `t` map to the same value, it is unspecified which
  2771. value maps to that key.
  2772. * `table.shuffle(table, [from], [to], [random_func])`:
  2773. * Shuffles elements `from` to `to` in `table` in place
  2774. * `from` defaults to `1`
  2775. * `to` defaults to `#table`
  2776. * `random_func` defaults to `math.random`. This function receives two
  2777. integers as arguments and should return a random integer inclusively
  2778. between them.
  2779. * `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a
  2780. position.
  2781. * returns the exact position on the surface of a pointed node
  2782. * `minetest.get_tool_wear_after_use(uses [, initial_wear])`
  2783. * Simulates a tool being used once and returns the added wear,
  2784. such that, if only this function is used to calculate wear,
  2785. the tool will break exactly after `uses` times of uses
  2786. * `uses`: Number of times the tool can be used
  2787. * `initial_wear`: The initial wear the tool starts with (default: 0)
  2788. * `minetest.get_dig_params(groups, tool_capabilities [, wear])`:
  2789. Simulates an item that digs a node.
  2790. Returns a table with the following fields:
  2791. * `diggable`: `true` if node can be dug, `false` otherwise.
  2792. * `time`: Time it would take to dig the node.
  2793. * `wear`: How much wear would be added to the tool (ignored for non-tools).
  2794. `time` and `wear` are meaningless if node's not diggable
  2795. Parameters:
  2796. * `groups`: Table of the node groups of the node that would be dug
  2797. * `tool_capabilities`: Tool capabilities table of the item
  2798. * `wear`: Amount of wear the tool starts with (default: 0)
  2799. * `minetest.get_hit_params(groups, tool_capabilities [, time_from_last_punch [, wear]])`:
  2800. Simulates an item that punches an object.
  2801. Returns a table with the following fields:
  2802. * `hp`: How much damage the punch would cause (between -65535 and 65535).
  2803. * `wear`: How much wear would be added to the tool (ignored for non-tools).
  2804. Parameters:
  2805. * `groups`: Damage groups of the object
  2806. * `tool_capabilities`: Tool capabilities table of the item
  2807. * `time_from_last_punch`: time in seconds since last punch action
  2808. * `wear`: Amount of wear the item starts with (default: 0)
  2809. Translations
  2810. ============
  2811. Texts can be translated client-side with the help of `minetest.translate` and
  2812. translation files.
  2813. Consider using the tool [update_translations](https://github.com/minetest-tools/update_translations)
  2814. to generate and update translation files automatically from the Lua source.
  2815. Translating a string
  2816. --------------------
  2817. Two functions are provided to translate strings: `minetest.translate` and
  2818. `minetest.get_translator`.
  2819. * `minetest.get_translator(textdomain)` is a simple wrapper around
  2820. `minetest.translate`, and `minetest.get_translator(textdomain)(str, ...)` is
  2821. equivalent to `minetest.translate(textdomain, str, ...)`.
  2822. It is intended to be used in the following way, so that it avoids verbose
  2823. repetitions of `minetest.translate`:
  2824. local S = minetest.get_translator(textdomain)
  2825. S(str, ...)
  2826. As an extra commodity, if `textdomain` is nil, it is assumed to be "" instead.
  2827. * `minetest.translate(textdomain, str, ...)` translates the string `str` with
  2828. the given `textdomain` for disambiguation. The textdomain must match the
  2829. textdomain specified in the translation file in order to get the string
  2830. translated. This can be used so that a string is translated differently in
  2831. different contexts.
  2832. It is advised to use the name of the mod as textdomain whenever possible, to
  2833. avoid clashes with other mods.
  2834. This function must be given a number of arguments equal to the number of
  2835. arguments the translated string expects.
  2836. Arguments are literal strings -- they will not be translated, so if you want
  2837. them to be, they need to come as outputs of `minetest.translate` as well.
  2838. For instance, suppose we want to translate "@1 Wool" with "@1" being replaced
  2839. by the translation of "Red". We can do the following:
  2840. local S = minetest.get_translator()
  2841. S("@1 Wool", S("Red"))
  2842. This will be displayed as "Red Wool" on old clients and on clients that do
  2843. not have localization enabled. However, if we have for instance a translation
  2844. file named `wool.fr.tr` containing the following:
  2845. @1 Wool=Laine @1
  2846. Red=Rouge
  2847. this will be displayed as "Laine Rouge" on clients with a French locale.
  2848. Operations on translated strings
  2849. --------------------------------
  2850. The output of `minetest.translate` is a string, with escape sequences adding
  2851. additional information to that string so that it can be translated on the
  2852. different clients. In particular, you can't expect operations like string.length
  2853. to work on them like you would expect them to, or string.gsub to work in the
  2854. expected manner. However, string concatenation will still work as expected
  2855. (note that you should only use this for things like formspecs; do not translate
  2856. sentences by breaking them into parts; arguments should be used instead), and
  2857. operations such as `minetest.colorize` which are also concatenation.
  2858. Translation file format
  2859. -----------------------
  2860. A translation file has the suffix `.[lang].tr`, where `[lang]` is the language
  2861. it corresponds to. It must be put into the `locale` subdirectory of the mod.
  2862. The file should be a text file, with the following format:
  2863. * Lines beginning with `# textdomain:` (the space is significant) can be used
  2864. to specify the text domain of all following translations in the file.
  2865. * All other empty lines or lines beginning with `#` are ignored.
  2866. * Other lines should be in the format `original=translated`. Both `original`
  2867. and `translated` can contain escape sequences beginning with `@` to insert
  2868. arguments, literal `@`, `=` or newline (See [Escapes] below).
  2869. There must be no extraneous whitespace around the `=` or at the beginning or
  2870. the end of the line.
  2871. Escapes
  2872. -------
  2873. Strings that need to be translated can contain several escapes, preceded by `@`.
  2874. * `@@` acts as a literal `@`.
  2875. * `@n`, where `n` is a digit between 1 and 9, is an argument for the translated
  2876. string that will be inlined when translated. Due to how translations are
  2877. implemented, the original translation string **must** have its arguments in
  2878. increasing order, without gaps or repetitions, starting from 1.
  2879. * `@=` acts as a literal `=`. It is not required in strings given to
  2880. `minetest.translate`, but is in translation files to avoid being confused
  2881. with the `=` separating the original from the translation.
  2882. * `@\n` (where the `\n` is a literal newline) acts as a literal newline.
  2883. As with `@=`, this escape is not required in strings given to
  2884. `minetest.translate`, but is in translation files.
  2885. * `@n` acts as a literal newline as well.
  2886. Server side translations
  2887. ------------------------
  2888. On some specific cases, server translation could be useful. For example, filter
  2889. a list on labels and send results to client. A method is supplied to achieve
  2890. that:
  2891. `minetest.get_translated_string(lang_code, string)`: Translates `string` using
  2892. translations for `lang_code` language. It gives the same result as if the string
  2893. was translated by the client.
  2894. The `lang_code` to use for a given player can be retrieved from
  2895. the table returned by `minetest.get_player_information(name)`.
  2896. IMPORTANT: This functionality should only be used for sorting, filtering or similar purposes.
  2897. You do not need to use this to get translated strings to show up on the client.
  2898. Perlin noise
  2899. ============
  2900. Perlin noise creates a continuously-varying value depending on the input values.
  2901. Usually in Minetest the input values are either 2D or 3D co-ordinates in nodes.
  2902. The result is used during map generation to create the terrain shape, vary heat
  2903. and humidity to distribute biomes, vary the density of decorations or vary the
  2904. structure of ores.
  2905. Structure of perlin noise
  2906. -------------------------
  2907. An 'octave' is a simple noise generator that outputs a value between -1 and 1.
  2908. The smooth wavy noise it generates has a single characteristic scale, almost
  2909. like a 'wavelength', so on its own does not create fine detail.
  2910. Due to this perlin noise combines several octaves to create variation on
  2911. multiple scales. Each additional octave has a smaller 'wavelength' than the
  2912. previous.
  2913. This combination results in noise varying very roughly between -2.0 and 2.0 and
  2914. with an average value of 0.0, so `scale` and `offset` are then used to multiply
  2915. and offset the noise variation.
  2916. The final perlin noise variation is created as follows:
  2917. noise = offset + scale * (octave1 +
  2918. octave2 * persistence +
  2919. octave3 * persistence ^ 2 +
  2920. octave4 * persistence ^ 3 +
  2921. ...)
  2922. Noise Parameters
  2923. ----------------
  2924. Noise Parameters are commonly called `NoiseParams`.
  2925. ### `offset`
  2926. After the multiplication by `scale` this is added to the result and is the final
  2927. step in creating the noise value.
  2928. Can be positive or negative.
  2929. ### `scale`
  2930. Once all octaves have been combined, the result is multiplied by this.
  2931. Can be positive or negative.
  2932. ### `spread`
  2933. For octave1, this is roughly the change of input value needed for a very large
  2934. variation in the noise value generated by octave1. It is almost like a
  2935. 'wavelength' for the wavy noise variation.
  2936. Each additional octave has a 'wavelength' that is smaller than the previous
  2937. octave, to create finer detail. `spread` will therefore roughly be the typical
  2938. size of the largest structures in the final noise variation.
  2939. `spread` is a vector with values for x, y, z to allow the noise variation to be
  2940. stretched or compressed in the desired axes.
  2941. Values are positive numbers.
  2942. ### `seed`
  2943. This is a whole number that determines the entire pattern of the noise
  2944. variation. Altering it enables different noise patterns to be created.
  2945. With other parameters equal, different seeds produce different noise patterns
  2946. and identical seeds produce identical noise patterns.
  2947. For this parameter you can randomly choose any whole number. Usually it is
  2948. preferable for this to be different from other seeds, but sometimes it is useful
  2949. to be able to create identical noise patterns.
  2950. In some noise APIs the world seed is added to the seed specified in noise
  2951. parameters. This is done to make the resulting noise pattern vary in different
  2952. worlds, and be 'world-specific'.
  2953. ### `octaves`
  2954. The number of simple noise generators that are combined.
  2955. A whole number, 1 or more.
  2956. Each additional octave adds finer detail to the noise but also increases the
  2957. noise calculation load.
  2958. 3 is a typical minimum for a high quality, complex and natural-looking noise
  2959. variation. 1 octave has a slight 'gridlike' appearance.
  2960. Choose the number of octaves according to the `spread` and `lacunarity`, and the
  2961. size of the finest detail you require. For example:
  2962. if `spread` is 512 nodes, `lacunarity` is 2.0 and finest detail required is 16
  2963. nodes, octaves will be 6 because the 'wavelengths' of the octaves will be
  2964. 512, 256, 128, 64, 32, 16 nodes.
  2965. Warning: If the 'wavelength' of any octave falls below 1 an error will occur.
  2966. ### `persistence`
  2967. Each additional octave has an amplitude that is the amplitude of the previous
  2968. octave multiplied by `persistence`, to reduce the amplitude of finer details,
  2969. as is often helpful and natural to do so.
  2970. Since this controls the balance of fine detail to large-scale detail
  2971. `persistence` can be thought of as the 'roughness' of the noise.
  2972. A positive or negative non-zero number, often between 0.3 and 1.0.
  2973. A common medium value is 0.5, such that each octave has half the amplitude of
  2974. the previous octave.
  2975. This may need to be tuned when altering `lacunarity`; when doing so consider
  2976. that a common medium value is 1 / lacunarity.
  2977. ### `lacunarity`
  2978. Each additional octave has a 'wavelength' that is the 'wavelength' of the
  2979. previous octave multiplied by 1 / lacunarity, to create finer detail.
  2980. 'lacunarity' is often 2.0 so 'wavelength' often halves per octave.
  2981. A positive number no smaller than 1.0.
  2982. Values below 2.0 create higher quality noise at the expense of requiring more
  2983. octaves to cover a paticular range of 'wavelengths'.
  2984. ### `flags`
  2985. Leave this field unset for no special handling.
  2986. Currently supported are `defaults`, `eased` and `absvalue`:
  2987. #### `defaults`
  2988. Specify this if you would like to keep auto-selection of eased/not-eased while
  2989. specifying some other flags.
  2990. #### `eased`
  2991. Maps noise gradient values onto a quintic S-curve before performing
  2992. interpolation. This results in smooth, rolling noise.
  2993. Disable this (`noeased`) for sharp-looking noise with a slightly gridded
  2994. appearence.
  2995. If no flags are specified (or defaults is), 2D noise is eased and 3D noise is
  2996. not eased.
  2997. Easing a 3D noise significantly increases the noise calculation load, so use
  2998. with restraint.
  2999. #### `absvalue`
  3000. The absolute value of each octave's noise variation is used when combining the
  3001. octaves. The final perlin noise variation is created as follows:
  3002. noise = offset + scale * (abs(octave1) +
  3003. abs(octave2) * persistence +
  3004. abs(octave3) * persistence ^ 2 +
  3005. abs(octave4) * persistence ^ 3 +
  3006. ...)
  3007. ### Format example
  3008. For 2D or 3D perlin noise or perlin noise maps:
  3009. np_terrain = {
  3010. offset = 0,
  3011. scale = 1,
  3012. spread = {x = 500, y = 500, z = 500},
  3013. seed = 571347,
  3014. octaves = 5,
  3015. persistence = 0.63,
  3016. lacunarity = 2.0,
  3017. flags = "defaults, absvalue",
  3018. }
  3019. For 2D noise the Z component of `spread` is still defined but is ignored.
  3020. A single noise parameter table can be used for 2D or 3D noise.
  3021. Ores
  3022. ====
  3023. Ore types
  3024. ---------
  3025. These tell in what manner the ore is generated.
  3026. All default ores are of the uniformly-distributed scatter type.
  3027. ### `scatter`
  3028. Randomly chooses a location and generates a cluster of ore.
  3029. If `noise_params` is specified, the ore will be placed if the 3D perlin noise
  3030. at that point is greater than the `noise_threshold`, giving the ability to
  3031. create a non-equal distribution of ore.
  3032. ### `sheet`
  3033. Creates a sheet of ore in a blob shape according to the 2D perlin noise
  3034. described by `noise_params` and `noise_threshold`. This is essentially an
  3035. improved version of the so-called "stratus" ore seen in some unofficial mods.
  3036. This sheet consists of vertical columns of uniform randomly distributed height,
  3037. varying between the inclusive range `column_height_min` and `column_height_max`.
  3038. If `column_height_min` is not specified, this parameter defaults to 1.
  3039. If `column_height_max` is not specified, this parameter defaults to `clust_size`
  3040. for reverse compatibility. New code should prefer `column_height_max`.
  3041. The `column_midpoint_factor` parameter controls the position of the column at
  3042. which ore emanates from.
  3043. If 1, columns grow upward. If 0, columns grow downward. If 0.5, columns grow
  3044. equally starting from each direction.
  3045. `column_midpoint_factor` is a decimal number ranging in value from 0 to 1. If
  3046. this parameter is not specified, the default is 0.5.
  3047. The ore parameters `clust_scarcity` and `clust_num_ores` are ignored for this
  3048. ore type.
  3049. ### `puff`
  3050. Creates a sheet of ore in a cloud-like puff shape.
  3051. As with the `sheet` ore type, the size and shape of puffs are described by
  3052. `noise_params` and `noise_threshold` and are placed at random vertical
  3053. positions within the currently generated chunk.
  3054. The vertical top and bottom displacement of each puff are determined by the
  3055. noise parameters `np_puff_top` and `np_puff_bottom`, respectively.
  3056. ### `blob`
  3057. Creates a deformed sphere of ore according to 3d perlin noise described by
  3058. `noise_params`. The maximum size of the blob is `clust_size`, and
  3059. `clust_scarcity` has the same meaning as with the `scatter` type.
  3060. ### `vein`
  3061. Creates veins of ore varying in density by according to the intersection of two
  3062. instances of 3d perlin noise with different seeds, both described by
  3063. `noise_params`.
  3064. `random_factor` varies the influence random chance has on placement of an ore
  3065. inside the vein, which is `1` by default. Note that modifying this parameter
  3066. may require adjusting `noise_threshold`.
  3067. The parameters `clust_scarcity`, `clust_num_ores`, and `clust_size` are ignored
  3068. by this ore type.
  3069. This ore type is difficult to control since it is sensitive to small changes.
  3070. The following is a decent set of parameters to work from:
  3071. noise_params = {
  3072. offset = 0,
  3073. scale = 3,
  3074. spread = {x=200, y=200, z=200},
  3075. seed = 5390,
  3076. octaves = 4,
  3077. persistence = 0.5,
  3078. lacunarity = 2.0,
  3079. flags = "eased",
  3080. },
  3081. noise_threshold = 1.6
  3082. **WARNING**: Use this ore type *very* sparingly since it is ~200x more
  3083. computationally expensive than any other ore.
  3084. ### `stratum`
  3085. Creates a single undulating ore stratum that is continuous across mapchunk
  3086. borders and horizontally spans the world.
  3087. The 2D perlin noise described by `noise_params` defines the Y co-ordinate of
  3088. the stratum midpoint. The 2D perlin noise described by `np_stratum_thickness`
  3089. defines the stratum's vertical thickness (in units of nodes). Due to being
  3090. continuous across mapchunk borders the stratum's vertical thickness is
  3091. unlimited.
  3092. If the noise parameter `noise_params` is omitted the ore will occur from y_min
  3093. to y_max in a simple horizontal stratum.
  3094. A parameter `stratum_thickness` can be provided instead of the noise parameter
  3095. `np_stratum_thickness`, to create a constant thickness.
  3096. Leaving out one or both noise parameters makes the ore generation less
  3097. intensive, useful when adding multiple strata.
  3098. `y_min` and `y_max` define the limits of the ore generation and for performance
  3099. reasons should be set as close together as possible but without clipping the
  3100. stratum's Y variation.
  3101. Each node in the stratum has a 1-in-`clust_scarcity` chance of being ore, so a
  3102. solid-ore stratum would require a `clust_scarcity` of 1.
  3103. The parameters `clust_num_ores`, `clust_size`, `noise_threshold` and
  3104. `random_factor` are ignored by this ore type.
  3105. Ore attributes
  3106. --------------
  3107. See section [Flag Specifier Format].
  3108. Currently supported flags:
  3109. `puff_cliffs`, `puff_additive_composition`.
  3110. ### `puff_cliffs`
  3111. If set, puff ore generation will not taper down large differences in
  3112. displacement when approaching the edge of a puff. This flag has no effect for
  3113. ore types other than `puff`.
  3114. ### `puff_additive_composition`
  3115. By default, when noise described by `np_puff_top` or `np_puff_bottom` results
  3116. in a negative displacement, the sub-column at that point is not generated. With
  3117. this attribute set, puff ore generation will instead generate the absolute
  3118. difference in noise displacement values. This flag has no effect for ore types
  3119. other than `puff`.
  3120. Decoration types
  3121. ================
  3122. The varying types of decorations that can be placed.
  3123. `simple`
  3124. --------
  3125. Creates a 1 times `H` times 1 column of a specified node (or a random node from
  3126. a list, if a decoration list is specified). Can specify a certain node it must
  3127. spawn next to, such as water or lava, for example. Can also generate a
  3128. decoration of random height between a specified lower and upper bound.
  3129. This type of decoration is intended for placement of grass, flowers, cacti,
  3130. papyri, waterlilies and so on.
  3131. `schematic`
  3132. -----------
  3133. Copies a box of `MapNodes` from a specified schematic file (or raw description).
  3134. Can specify a probability of a node randomly appearing when placed.
  3135. This decoration type is intended to be used for multi-node sized discrete
  3136. structures, such as trees, cave spikes, rocks, and so on.
  3137. Schematics
  3138. ==========
  3139. Schematic specifier
  3140. --------------------
  3141. A schematic specifier identifies a schematic by either a filename to a
  3142. Minetest Schematic file (`.mts`) or through raw data supplied through Lua,
  3143. in the form of a table. This table specifies the following fields:
  3144. * The `size` field is a 3D vector containing the dimensions of the provided
  3145. schematic. (required field)
  3146. * The `yslice_prob` field is a table of {ypos, prob} slice tables. A slice table
  3147. sets the probability of a particular horizontal slice of the schematic being
  3148. placed. (optional field)
  3149. `ypos` = 0 for the lowest horizontal slice of a schematic.
  3150. The default of `prob` is 255.
  3151. * The `data` field is a flat table of MapNode tables making up the schematic,
  3152. in the order of `[z [y [x]]]`. (required field)
  3153. Each MapNode table contains:
  3154. * `name`: the name of the map node to place (required)
  3155. * `prob` (alias `param1`): the probability of this node being placed
  3156. (default: 255)
  3157. * `param2`: the raw param2 value of the node being placed onto the map
  3158. (default: 0)
  3159. * `force_place`: boolean representing if the node should forcibly overwrite
  3160. any previous contents (default: false)
  3161. About probability values:
  3162. * A probability value of `0` or `1` means that node will never appear
  3163. (0% chance).
  3164. * A probability value of `254` or `255` means the node will always appear
  3165. (100% chance).
  3166. * If the probability value `p` is greater than `1`, then there is a
  3167. `(p / 256 * 100)` percent chance that node will appear when the schematic is
  3168. placed on the map.
  3169. Schematic attributes
  3170. --------------------
  3171. See section [Flag Specifier Format].
  3172. Currently supported flags: `place_center_x`, `place_center_y`, `place_center_z`,
  3173. `force_placement`.
  3174. * `place_center_x`: Placement of this decoration is centered along the X axis.
  3175. * `place_center_y`: Placement of this decoration is centered along the Y axis.
  3176. * `place_center_z`: Placement of this decoration is centered along the Z axis.
  3177. * `force_placement`: Schematic nodes other than "ignore" will replace existing
  3178. nodes.
  3179. Lua Voxel Manipulator
  3180. =====================
  3181. About VoxelManip
  3182. ----------------
  3183. VoxelManip is a scripting interface to the internal 'Map Voxel Manipulator'
  3184. facility. The purpose of this object is for fast, low-level, bulk access to
  3185. reading and writing Map content. As such, setting map nodes through VoxelManip
  3186. will lack many of the higher level features and concepts you may be used to
  3187. with other methods of setting nodes. For example, nodes will not have their
  3188. construction and destruction callbacks run, and no rollback information is
  3189. logged.
  3190. It is important to note that VoxelManip is designed for speed, and *not* ease
  3191. of use or flexibility. If your mod requires a map manipulation facility that
  3192. will handle 100% of all edge cases, or the use of high level node placement
  3193. features, perhaps `minetest.set_node()` is better suited for the job.
  3194. In addition, VoxelManip might not be faster, or could even be slower, for your
  3195. specific use case. VoxelManip is most effective when setting large areas of map
  3196. at once - for example, if only setting a 3x3x3 node area, a
  3197. `minetest.set_node()` loop may be more optimal. Always profile code using both
  3198. methods of map manipulation to determine which is most appropriate for your
  3199. usage.
  3200. A recent simple test of setting cubic areas showed that `minetest.set_node()`
  3201. is faster than a VoxelManip for a 3x3x3 node cube or smaller.
  3202. Using VoxelManip
  3203. ----------------
  3204. A VoxelManip object can be created any time using either:
  3205. `VoxelManip([p1, p2])`, or `minetest.get_voxel_manip([p1, p2])`.
  3206. If the optional position parameters are present for either of these routines,
  3207. the specified region will be pre-loaded into the VoxelManip object on creation.
  3208. Otherwise, the area of map you wish to manipulate must first be loaded into the
  3209. VoxelManip object using `VoxelManip:read_from_map()`.
  3210. Note that `VoxelManip:read_from_map()` returns two position vectors. The region
  3211. formed by these positions indicate the minimum and maximum (respectively)
  3212. positions of the area actually loaded in the VoxelManip, which may be larger
  3213. than the area requested. For convenience, the loaded area coordinates can also
  3214. be queried any time after loading map data with `VoxelManip:get_emerged_area()`.
  3215. Now that the VoxelManip object is populated with map data, your mod can fetch a
  3216. copy of this data using either of two methods. `VoxelManip:get_node_at()`,
  3217. which retrieves an individual node in a MapNode formatted table at the position
  3218. requested is the simplest method to use, but also the slowest.
  3219. Nodes in a VoxelManip object may also be read in bulk to a flat array table
  3220. using:
  3221. * `VoxelManip:get_data()` for node content (in Content ID form, see section
  3222. [Content IDs]),
  3223. * `VoxelManip:get_light_data()` for node light levels, and
  3224. * `VoxelManip:get_param2_data()` for the node type-dependent "param2" values.
  3225. See section [Flat array format] for more details.
  3226. It is very important to understand that the tables returned by any of the above
  3227. three functions represent a snapshot of the VoxelManip's internal state at the
  3228. time of the call. This copy of the data will not magically update itself if
  3229. another function modifies the internal VoxelManip state.
  3230. Any functions that modify a VoxelManip's contents work on the VoxelManip's
  3231. internal state unless otherwise explicitly stated.
  3232. Once the bulk data has been edited to your liking, the internal VoxelManip
  3233. state can be set using:
  3234. * `VoxelManip:set_data()` for node content (in Content ID form, see section
  3235. [Content IDs]),
  3236. * `VoxelManip:set_light_data()` for node light levels, and
  3237. * `VoxelManip:set_param2_data()` for the node type-dependent `param2` values.
  3238. The parameter to each of the above three functions can use any table at all in
  3239. the same flat array format as produced by `get_data()` etc. and is not required
  3240. to be a table retrieved from `get_data()`.
  3241. Once the internal VoxelManip state has been modified to your liking, the
  3242. changes can be committed back to the map by calling `VoxelManip:write_to_map()`
  3243. ### Flat array format
  3244. Let
  3245. `Nx = p2.X - p1.X + 1`,
  3246. `Ny = p2.Y - p1.Y + 1`, and
  3247. `Nz = p2.Z - p1.Z + 1`.
  3248. Then, for a loaded region of p1..p2, this array ranges from `1` up to and
  3249. including the value of the expression `Nx * Ny * Nz`.
  3250. Positions offset from p1 are present in the array with the format of:
  3251. [
  3252. (0, 0, 0), (1, 0, 0), (2, 0, 0), ... (Nx, 0, 0),
  3253. (0, 1, 0), (1, 1, 0), (2, 1, 0), ... (Nx, 1, 0),
  3254. ...
  3255. (0, Ny, 0), (1, Ny, 0), (2, Ny, 0), ... (Nx, Ny, 0),
  3256. (0, 0, 1), (1, 0, 1), (2, 0, 1), ... (Nx, 0, 1),
  3257. ...
  3258. (0, Ny, 2), (1, Ny, 2), (2, Ny, 2), ... (Nx, Ny, 2),
  3259. ...
  3260. (0, Ny, Nz), (1, Ny, Nz), (2, Ny, Nz), ... (Nx, Ny, Nz)
  3261. ]
  3262. and the array index for a position p contained completely in p1..p2 is:
  3263. `(p.Z - p1.Z) * Ny * Nx + (p.Y - p1.Y) * Nx + (p.X - p1.X) + 1`
  3264. Note that this is the same "flat 3D array" format as
  3265. `PerlinNoiseMap:get3dMap_flat()`.
  3266. VoxelArea objects (see section [`VoxelArea`]) can be used to simplify calculation
  3267. of the index for a single point in a flat VoxelManip array.
  3268. ### Content IDs
  3269. A Content ID is a unique integer identifier for a specific node type.
  3270. These IDs are used by VoxelManip in place of the node name string for
  3271. `VoxelManip:get_data()` and `VoxelManip:set_data()`. You can use
  3272. `minetest.get_content_id()` to look up the Content ID for the specified node
  3273. name, and `minetest.get_name_from_content_id()` to look up the node name string
  3274. for a given Content ID.
  3275. After registration of a node, its Content ID will remain the same throughout
  3276. execution of the mod.
  3277. Note that the node being queried needs to have already been been registered.
  3278. The following builtin node types have their Content IDs defined as constants:
  3279. * `minetest.CONTENT_UNKNOWN`: ID for "unknown" nodes
  3280. * `minetest.CONTENT_AIR`: ID for "air" nodes
  3281. * `minetest.CONTENT_IGNORE`: ID for "ignore" nodes
  3282. ### Mapgen VoxelManip objects
  3283. Inside of `on_generated()` callbacks, it is possible to retrieve the same
  3284. VoxelManip object used by the core's Map Generator (commonly abbreviated
  3285. Mapgen). Most of the rules previously described still apply but with a few
  3286. differences:
  3287. * The Mapgen VoxelManip object is retrieved using:
  3288. `minetest.get_mapgen_object("voxelmanip")`
  3289. * This VoxelManip object already has the region of map just generated loaded
  3290. into it; it's not necessary to call `VoxelManip:read_from_map()`.
  3291. Note that the region of map it has loaded is NOT THE SAME as the `minp`, `maxp`
  3292. parameters of `on_generated()`. Refer to `minetest.get_mapgen_object` docs.
  3293. * The `on_generated()` callbacks of some mods may place individual nodes in the
  3294. generated area using non-VoxelManip map modification methods. Because the
  3295. same Mapgen VoxelManip object is passed through each `on_generated()`
  3296. callback, it becomes necessary for the Mapgen VoxelManip object to maintain
  3297. consistency with the current map state. For this reason, calling any of
  3298. `minetest.add_node()`, `minetest.set_node()` or `minetest.swap_node()`
  3299. will also update the Mapgen VoxelManip object's internal state active on the
  3300. current thread.
  3301. * After modifying the Mapgen VoxelManip object's internal buffer, it may be
  3302. necessary to update lighting information using either:
  3303. `VoxelManip:calc_lighting()` or `VoxelManip:set_lighting()`.
  3304. ### Other API functions operating on a VoxelManip
  3305. If any VoxelManip contents were set to a liquid node (`liquidtype ~= "none"`),
  3306. `VoxelManip:update_liquids()` must be called for these liquid nodes to begin
  3307. flowing. It is recommended to call this function only after having written all
  3308. buffered data back to the VoxelManip object, save for special situations where
  3309. the modder desires to only have certain liquid nodes begin flowing.
  3310. The functions `minetest.generate_ores()` and `minetest.generate_decorations()`
  3311. will generate all registered decorations and ores throughout the full area
  3312. inside of the specified VoxelManip object.
  3313. `minetest.place_schematic_on_vmanip()` is otherwise identical to
  3314. `minetest.place_schematic()`, except instead of placing the specified schematic
  3315. directly on the map at the specified position, it will place the schematic
  3316. inside the VoxelManip.
  3317. ### Notes
  3318. * Attempting to read data from a VoxelManip object before map is read will
  3319. result in a zero-length array table for `VoxelManip:get_data()`, and an
  3320. "ignore" node at any position for `VoxelManip:get_node_at()`.
  3321. * If either a region of map has not yet been generated or is out-of-bounds of
  3322. the map, that region is filled with "ignore" nodes.
  3323. * Other mods, or the core itself, could possibly modify the area of map
  3324. currently loaded into a VoxelManip object. With the exception of Mapgen
  3325. VoxelManips (see above section), the internal buffers are not updated. For
  3326. this reason, it is strongly encouraged to complete the usage of a particular
  3327. VoxelManip object in the same callback it had been created.
  3328. * If a VoxelManip object will be used often, such as in an `on_generated()`
  3329. callback, consider passing a file-scoped table as the optional parameter to
  3330. `VoxelManip:get_data()`, which serves as a static buffer the function can use
  3331. to write map data to instead of returning a new table each call. This greatly
  3332. enhances performance by avoiding unnecessary memory allocations.
  3333. Methods
  3334. -------
  3335. * `read_from_map(p1, p2)`: Loads a chunk of map into the VoxelManip object
  3336. containing the region formed by `p1` and `p2`.
  3337. * returns actual emerged `pmin`, actual emerged `pmax`
  3338. * `write_to_map([light])`: Writes the data loaded from the `VoxelManip` back to
  3339. the map.
  3340. * **important**: data must be set using `VoxelManip:set_data()` before
  3341. calling this.
  3342. * if `light` is true, then lighting is automatically recalculated.
  3343. The default value is true.
  3344. If `light` is false, no light calculations happen, and you should correct
  3345. all modified blocks with `minetest.fix_light()` as soon as possible.
  3346. Keep in mind that modifying the map where light is incorrect can cause
  3347. more lighting bugs.
  3348. * `get_node_at(pos)`: Returns a `MapNode` table of the node currently loaded in
  3349. the `VoxelManip` at that position
  3350. * `set_node_at(pos, node)`: Sets a specific `MapNode` in the `VoxelManip` at
  3351. that position.
  3352. * `get_data([buffer])`: Retrieves the node content data loaded into the
  3353. `VoxelManip` object.
  3354. * returns raw node data in the form of an array of node content IDs
  3355. * if the param `buffer` is present, this table will be used to store the
  3356. result instead.
  3357. * `set_data(data)`: Sets the data contents of the `VoxelManip` object
  3358. * `update_map()`: Does nothing, kept for compatibility.
  3359. * `set_lighting(light, [p1, p2])`: Set the lighting within the `VoxelManip` to
  3360. a uniform value.
  3361. * `light` is a table, `{day=<0...15>, night=<0...15>}`
  3362. * To be used only by a `VoxelManip` object from
  3363. `minetest.get_mapgen_object`.
  3364. * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
  3365. area if left out.
  3366. * `get_light_data()`: Gets the light data read into the `VoxelManip` object
  3367. * Returns an array (indices 1 to volume) of integers ranging from `0` to
  3368. `255`.
  3369. * Each value is the bitwise combination of day and night light values
  3370. (`0` to `15` each).
  3371. * `light = day + (night * 16)`
  3372. * `set_light_data(light_data)`: Sets the `param1` (light) contents of each node
  3373. in the `VoxelManip`.
  3374. * expects lighting data in the same format that `get_light_data()` returns
  3375. * `get_param2_data([buffer])`: Gets the raw `param2` data read into the
  3376. `VoxelManip` object.
  3377. * Returns an array (indices 1 to volume) of integers ranging from `0` to
  3378. `255`.
  3379. * If the param `buffer` is present, this table will be used to store the
  3380. result instead.
  3381. * `set_param2_data(param2_data)`: Sets the `param2` contents of each node in
  3382. the `VoxelManip`.
  3383. * `calc_lighting([p1, p2], [propagate_shadow])`: Calculate lighting within the
  3384. `VoxelManip`.
  3385. * To be used only by a `VoxelManip` object from
  3386. `minetest.get_mapgen_object`.
  3387. * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
  3388. area if left out or nil. For almost all uses these should be left out
  3389. or nil to use the default.
  3390. * `propagate_shadow` is an optional boolean deciding whether shadows in a
  3391. generated mapchunk above are propagated down into the mapchunk, defaults
  3392. to `true` if left out.
  3393. * `update_liquids()`: Update liquid flow
  3394. * `was_modified()`: Returns `true` or `false` if the data in the voxel
  3395. manipulator had been modified since the last read from map, due to a call to
  3396. `minetest.set_data()` on the loaded area elsewhere.
  3397. * `get_emerged_area()`: Returns actual emerged minimum and maximum positions.
  3398. `VoxelArea`
  3399. -----------
  3400. A helper class for voxel areas.
  3401. It can be created via `VoxelArea:new({MinEdge = pmin, MaxEdge = pmax})`.
  3402. The coordinates are *inclusive*, like most other things in Minetest.
  3403. ### Methods
  3404. * `getExtent()`: returns a 3D vector containing the size of the area formed by
  3405. `MinEdge` and `MaxEdge`.
  3406. * `getVolume()`: returns the volume of the area formed by `MinEdge` and
  3407. `MaxEdge`.
  3408. * `index(x, y, z)`: returns the index of an absolute position in a flat array
  3409. starting at `1`.
  3410. * `x`, `y` and `z` must be integers to avoid an incorrect index result.
  3411. * The position (x, y, z) is not checked for being inside the area volume,
  3412. being outside can cause an incorrect index result.
  3413. * Useful for things like `VoxelManip`, raw Schematic specifiers,
  3414. `PerlinNoiseMap:get2d`/`3dMap`, and so on.
  3415. * `indexp(p)`: same functionality as `index(x, y, z)` but takes a vector.
  3416. * As with `index(x, y, z)`, the components of `p` must be integers, and `p`
  3417. is not checked for being inside the area volume.
  3418. * `position(i)`: returns the absolute position vector corresponding to index
  3419. `i`.
  3420. * `contains(x, y, z)`: check if (`x`,`y`,`z`) is inside area formed by
  3421. `MinEdge` and `MaxEdge`.
  3422. * `containsp(p)`: same as above, except takes a vector
  3423. * `containsi(i)`: same as above, except takes an index `i`
  3424. * `iter(minx, miny, minz, maxx, maxy, maxz)`: returns an iterator that returns
  3425. indices.
  3426. * from (`minx`,`miny`,`minz`) to (`maxx`,`maxy`,`maxz`) in the order of
  3427. `[z [y [x]]]`.
  3428. * `iterp(minp, maxp)`: same as above, except takes a vector
  3429. ### Y stride and z stride of a flat array
  3430. For a particular position in a voxel area, whose flat array index is known,
  3431. it is often useful to know the index of a neighboring or nearby position.
  3432. The table below shows the changes of index required for 1 node movements along
  3433. the axes in a voxel area:
  3434. Movement Change of index
  3435. +x +1
  3436. -x -1
  3437. +y +ystride
  3438. -y -ystride
  3439. +z +zstride
  3440. -z -zstride
  3441. If, for example:
  3442. local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
  3443. The values of `ystride` and `zstride` can be obtained using `area.ystride` and
  3444. `area.zstride`.
  3445. Mapgen objects
  3446. ==============
  3447. A mapgen object is a construct used in map generation. Mapgen objects can be
  3448. used by an `on_generate` callback to speed up operations by avoiding
  3449. unnecessary recalculations, these can be retrieved using the
  3450. `minetest.get_mapgen_object()` function. If the requested Mapgen object is
  3451. unavailable, or `get_mapgen_object()` was called outside of an `on_generate()`
  3452. callback, `nil` is returned.
  3453. The following Mapgen objects are currently available:
  3454. ### `voxelmanip`
  3455. This returns three values; the `VoxelManip` object to be used, minimum and
  3456. maximum emerged position, in that order. All mapgens support this object.
  3457. ### `heightmap`
  3458. Returns an array containing the y coordinates of the ground levels of nodes in
  3459. the most recently generated chunk by the current mapgen.
  3460. ### `biomemap`
  3461. Returns an array containing the biome IDs of nodes in the most recently
  3462. generated chunk by the current mapgen.
  3463. ### `heatmap`
  3464. Returns an array containing the temperature values of nodes in the most
  3465. recently generated chunk by the current mapgen.
  3466. ### `humiditymap`
  3467. Returns an array containing the humidity values of nodes in the most recently
  3468. generated chunk by the current mapgen.
  3469. ### `gennotify`
  3470. Returns a table mapping requested generation notification types to arrays of
  3471. positions at which the corresponding generated structures are located within
  3472. the current chunk. To enable the capture of positions of interest to be recorded
  3473. call `minetest.set_gen_notify()` first.
  3474. Possible fields of the returned table are:
  3475. * `dungeon`: bottom center position of dungeon rooms
  3476. * `temple`: as above but for desert temples (mgv6 only)
  3477. * `cave_begin`
  3478. * `cave_end`
  3479. * `large_cave_begin`
  3480. * `large_cave_end`
  3481. * `decoration#id` (see below)
  3482. Decorations have a key in the format of `"decoration#id"`, where `id` is the
  3483. numeric unique decoration ID as returned by `minetest.get_decoration_id()`.
  3484. For example, `decoration#123`.
  3485. The returned positions are the ground surface 'place_on' nodes,
  3486. not the decorations themselves. A 'simple' type decoration is often 1
  3487. node above the returned position and possibly displaced by 'place_offset_y'.
  3488. Registered entities
  3489. ===================
  3490. Functions receive a "luaentity" table as `self`:
  3491. * It has the member `name`, which is the registered name `("mod:thing")`
  3492. * It has the member `object`, which is an `ObjectRef` pointing to the object
  3493. * The original prototype is visible directly via a metatable
  3494. Callbacks:
  3495. * `on_activate(self, staticdata, dtime_s)`
  3496. * Called when the object is instantiated.
  3497. * `dtime_s` is the time passed since the object was unloaded, which can be
  3498. used for updating the entity state.
  3499. * `on_deactivate(self, removal)`
  3500. * Called when the object is about to get removed or unloaded.
  3501. * `removal`: boolean indicating whether the object is about to get removed.
  3502. Calling `object:remove()` on an active object will call this with `removal=true`.
  3503. The mapblock the entity resides in being unloaded will call this with `removal=false`.
  3504. * Note that this won't be called if the object hasn't been activated in the first place.
  3505. In particular, `minetest.clear_objects({mode = "full"})` won't call this,
  3506. whereas `minetest.clear_objects({mode = "quick"})` might call this.
  3507. * `on_step(self, dtime, moveresult)`
  3508. * Called on every server tick, after movement and collision processing.
  3509. * `dtime`: elapsed time since last call
  3510. * `moveresult`: table with collision info (only available if physical=true)
  3511. * `on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)`
  3512. * Called when somebody punches the object.
  3513. * Note that you probably want to handle most punches using the automatic
  3514. armor group system.
  3515. * `puncher`: an `ObjectRef` (can be `nil`)
  3516. * `time_from_last_punch`: Meant for disallowing spamming of clicks
  3517. (can be `nil`).
  3518. * `tool_capabilities`: capability table of used item (can be `nil`)
  3519. * `dir`: unit vector of direction of punch. Always defined. Points from the
  3520. puncher to the punched.
  3521. * `damage`: damage that will be done to entity.
  3522. * Can return `true` to prevent the default damage mechanism.
  3523. * `on_death(self, killer)`
  3524. * Called when the object dies.
  3525. * `killer`: an `ObjectRef` (can be `nil`)
  3526. * `on_rightclick(self, clicker)`
  3527. * Called when `clicker` pressed the 'place/use' key while pointing
  3528. to the object (not neccessarily an actual rightclick)
  3529. * `clicker`: an `ObjectRef` (may or may not be a player)
  3530. * `on_attach_child(self, child)`
  3531. * `child`: an `ObjectRef` of the child that attaches
  3532. * `on_detach_child(self, child)`
  3533. * `child`: an `ObjectRef` of the child that detaches
  3534. * `on_detach(self, parent)`
  3535. * `parent`: an `ObjectRef` (can be `nil`) from where it got detached
  3536. * This happens before the parent object is removed from the world
  3537. * `get_staticdata(self)`
  3538. * Should return a string that will be passed to `on_activate` when the
  3539. object is instantiated the next time.
  3540. Collision info passed to `on_step` (`moveresult` argument):
  3541. {
  3542. touching_ground = boolean,
  3543. -- Note that touching_ground is only true if the entity was moving and
  3544. -- collided with ground.
  3545. collides = boolean,
  3546. standing_on_object = boolean,
  3547. collisions = {
  3548. {
  3549. type = string, -- "node" or "object",
  3550. axis = string, -- "x", "y" or "z"
  3551. node_pos = vector, -- if type is "node"
  3552. object = ObjectRef, -- if type is "object"
  3553. old_velocity = vector,
  3554. new_velocity = vector,
  3555. },
  3556. ...
  3557. }
  3558. -- `collisions` does not contain data of unloaded mapblock collisions
  3559. -- or when the velocity changes are negligibly small
  3560. }
  3561. L-system trees
  3562. ==============
  3563. Tree definition
  3564. ---------------
  3565. treedef={
  3566. axiom, --string initial tree axiom
  3567. rules_a, --string rules set A
  3568. rules_b, --string rules set B
  3569. rules_c, --string rules set C
  3570. rules_d, --string rules set D
  3571. trunk, --string trunk node name
  3572. leaves, --string leaves node name
  3573. leaves2, --string secondary leaves node name
  3574. leaves2_chance,--num chance (0-100) to replace leaves with leaves2
  3575. angle, --num angle in deg
  3576. iterations, --num max # of iterations, usually 2 -5
  3577. random_level, --num factor to lower nr of iterations, usually 0 - 3
  3578. trunk_type, --string single/double/crossed) type of trunk: 1 node,
  3579. -- 2x2 nodes or 3x3 in cross shape
  3580. thin_branches, --boolean true -> use thin (1 node) branches
  3581. fruit, --string fruit node name
  3582. fruit_chance, --num chance (0-100) to replace leaves with fruit node
  3583. seed, --num random seed, if no seed is provided, the engine
  3584. will create one.
  3585. }
  3586. Key for special L-System symbols used in axioms
  3587. -----------------------------------------------
  3588. * `G`: move forward one unit with the pen up
  3589. * `F`: move forward one unit with the pen down drawing trunks and branches
  3590. * `f`: move forward one unit with the pen down drawing leaves (100% chance)
  3591. * `T`: move forward one unit with the pen down drawing trunks only
  3592. * `R`: move forward one unit with the pen down placing fruit
  3593. * `A`: replace with rules set A
  3594. * `B`: replace with rules set B
  3595. * `C`: replace with rules set C
  3596. * `D`: replace with rules set D
  3597. * `a`: replace with rules set A, chance 90%
  3598. * `b`: replace with rules set B, chance 80%
  3599. * `c`: replace with rules set C, chance 70%
  3600. * `d`: replace with rules set D, chance 60%
  3601. * `+`: yaw the turtle right by `angle` parameter
  3602. * `-`: yaw the turtle left by `angle` parameter
  3603. * `&`: pitch the turtle down by `angle` parameter
  3604. * `^`: pitch the turtle up by `angle` parameter
  3605. * `/`: roll the turtle to the right by `angle` parameter
  3606. * `*`: roll the turtle to the left by `angle` parameter
  3607. * `[`: save in stack current state info
  3608. * `]`: recover from stack state info
  3609. Example
  3610. -------
  3611. Spawn a small apple tree:
  3612. pos = {x=230,y=20,z=4}
  3613. apple_tree={
  3614. axiom="FFFFFAFFBF",
  3615. rules_a="[&&&FFFFF&&FFFF][&&&++++FFFFF&&FFFF][&&&----FFFFF&&FFFF]",
  3616. rules_b="[&&&++FFFFF&&FFFF][&&&--FFFFF&&FFFF][&&&------FFFFF&&FFFF]",
  3617. trunk="default:tree",
  3618. leaves="default:leaves",
  3619. angle=30,
  3620. iterations=2,
  3621. random_level=0,
  3622. trunk_type="single",
  3623. thin_branches=true,
  3624. fruit_chance=10,
  3625. fruit="default:apple"
  3626. }
  3627. minetest.spawn_tree(pos,apple_tree)
  3628. Privileges
  3629. ==========
  3630. Privileges provide a means for server administrators to give certain players
  3631. access to special abilities in the engine, games or mods.
  3632. For example, game moderators may need to travel instantly to any place in the world,
  3633. this ability is implemented in `/teleport` command which requires `teleport` privilege.
  3634. Registering privileges
  3635. ----------------------
  3636. A mod can register a custom privilege using `minetest.register_privilege` function
  3637. to give server administrators fine-grained access control over mod functionality.
  3638. For consistency and practical reasons, privileges should strictly increase the abilities of the user.
  3639. Do not register custom privileges that e.g. restrict the player from certain in-game actions.
  3640. Checking privileges
  3641. -------------------
  3642. A mod can call `minetest.check_player_privs` to test whether a player has privileges
  3643. to perform an operation.
  3644. Also, when registering a chat command with `minetest.register_chatcommand` a mod can
  3645. declare privileges that the command requires using the `privs` field of the command
  3646. definition.
  3647. Managing player privileges
  3648. --------------------------
  3649. A mod can update player privileges using `minetest.set_player_privs` function.
  3650. Players holding the `privs` privilege can see and manage privileges for all
  3651. players on the server.
  3652. A mod can subscribe to changes in player privileges using `minetest.register_on_priv_grant`
  3653. and `minetest.register_on_priv_revoke` functions.
  3654. Built-in privileges
  3655. -------------------
  3656. Minetest includes a set of built-in privileges that control capabilities
  3657. provided by the Minetest engine and can be used by mods:
  3658. * Basic privileges are normally granted to all players:
  3659. * `shout`: can communicate using the in-game chat.
  3660. * `interact`: can modify the world by digging, building and interacting
  3661. with the nodes, entities and other players. Players without the `interact`
  3662. privilege can only travel and observe the world.
  3663. * Advanced privileges allow bypassing certain aspects of the gameplay:
  3664. * `fast`: can use "fast mode" to move with maximum speed.
  3665. * `fly`: can use "fly mode" to move freely above the ground without falling.
  3666. * `noclip`: can use "noclip mode" to fly through solid nodes (e.g. walls).
  3667. * `teleport`: can use `/teleport` command to move to any point in the world.
  3668. * `creative`: can access creative inventory.
  3669. * `bring`: can teleport other players to oneself.
  3670. * `give`: can use `/give` and `/giveme` commands to give any item
  3671. in the game to oneself or others.
  3672. * `settime`: can use `/time` command to change current in-game time.
  3673. * `debug`: can enable wireframe rendering mode.
  3674. * Security-related privileges:
  3675. * `privs`: can modify privileges of the players using `/grant[me]` and
  3676. `/revoke[me]` commands.
  3677. * `basic_privs`: can grant and revoke basic privileges as defined by
  3678. the `basic_privs` setting.
  3679. * `kick`: can kick other players from the server using `/kick` command.
  3680. * `ban`: can ban other players using `/ban` command.
  3681. * `password`: can use `/setpassword` and `/clearpassword` commands
  3682. to manage players' passwords.
  3683. * `protection_bypass`: can bypass node protection. Note that the engine does not act upon this privilege,
  3684. it is only an implementation suggestion for games.
  3685. * Administrative privileges:
  3686. * `server`: can use `/fixlight`, `/deleteblocks` and `/deleteobjects`
  3687. commands. Can clear inventory of other players using `/clearinv` command.
  3688. * `rollback`: can use `/rollback_check` and `/rollback` commands.
  3689. Related settings
  3690. ----------------
  3691. Minetest includes the following settings to control behavior of privileges:
  3692. * `default_privs`: defines privileges granted to new players.
  3693. * `basic_privs`: defines privileges that can be granted/revoked by players having
  3694. the `basic_privs` privilege. This can be used, for example, to give
  3695. limited moderation powers to selected users.
  3696. 'minetest' namespace reference
  3697. ==============================
  3698. Utilities
  3699. ---------
  3700. * `minetest.get_current_modname()`: returns the currently loading mod's name,
  3701. when loading a mod.
  3702. * `minetest.get_modpath(modname)`: returns the directory path for a mod,
  3703. e.g. `"/home/user/.minetest/usermods/modname"`.
  3704. * Returns nil if the mod is not enabled or does not exist (not installed).
  3705. * Works regardless of whether the mod has been loaded yet.
  3706. * Useful for loading additional `.lua` modules or static data from a mod,
  3707. or checking if a mod is enabled.
  3708. * `minetest.get_modnames()`: returns a list of enabled mods, sorted alphabetically.
  3709. * Does not include disabled mods, even if they are installed.
  3710. * `minetest.get_worldpath()`: returns e.g. `"/home/user/.minetest/world"`
  3711. * Useful for storing custom data
  3712. * `minetest.is_singleplayer()`
  3713. * `minetest.features`: Table containing API feature flags
  3714. {
  3715. glasslike_framed = true, -- 0.4.7
  3716. nodebox_as_selectionbox = true, -- 0.4.7
  3717. get_all_craft_recipes_works = true, -- 0.4.7
  3718. -- The transparency channel of textures can optionally be used on
  3719. -- nodes (0.4.7)
  3720. use_texture_alpha = true,
  3721. -- Tree and grass ABMs are no longer done from C++ (0.4.8)
  3722. no_legacy_abms = true,
  3723. -- Texture grouping is possible using parentheses (0.4.11)
  3724. texture_names_parens = true,
  3725. -- Unique Area ID for AreaStore:insert_area (0.4.14)
  3726. area_store_custom_ids = true,
  3727. -- add_entity supports passing initial staticdata to on_activate
  3728. -- (0.4.16)
  3729. add_entity_with_staticdata = true,
  3730. -- Chat messages are no longer predicted (0.4.16)
  3731. no_chat_message_prediction = true,
  3732. -- The transparency channel of textures can optionally be used on
  3733. -- objects (ie: players and lua entities) (5.0.0)
  3734. object_use_texture_alpha = true,
  3735. -- Object selectionbox is settable independently from collisionbox
  3736. -- (5.0.0)
  3737. object_independent_selectionbox = true,
  3738. -- Specifies whether binary data can be uploaded or downloaded using
  3739. -- the HTTP API (5.1.0)
  3740. httpfetch_binary_data = true,
  3741. -- Whether formspec_version[<version>] may be used (5.1.0)
  3742. formspec_version_element = true,
  3743. -- Whether AreaStore's IDs are kept on save/load (5.1.0)
  3744. area_store_persistent_ids = true,
  3745. -- Whether minetest.find_path is functional (5.2.0)
  3746. pathfinder_works = true,
  3747. -- Whether Collision info is available to an objects' on_step (5.3.0)
  3748. object_step_has_moveresult = true,
  3749. -- Whether get_velocity() and add_velocity() can be used on players (5.4.0)
  3750. direct_velocity_on_players = true,
  3751. -- nodedef's use_texture_alpha accepts new string modes (5.4.0)
  3752. use_texture_alpha_string_modes = true,
  3753. -- degrotate param2 rotates in units of 1.5° instead of 2°
  3754. -- thus changing the range of values from 0-179 to 0-240 (5.5.0)
  3755. degrotate_240_steps = true,
  3756. -- ABM supports min_y and max_y fields in definition (5.5.0)
  3757. abm_min_max_y = true,
  3758. -- dynamic_add_media supports passing a table with options (5.5.0)
  3759. dynamic_add_media_table = true,
  3760. -- particlespawners support texpools and animation of properties,
  3761. -- particle textures support smooth fade and scale animations, and
  3762. -- sprite-sheet particle animations can by synced to the lifetime
  3763. -- of individual particles (5.6.0)
  3764. particlespawner_tweenable = true,
  3765. -- allows get_sky to return a table instead of separate values (5.6.0)
  3766. get_sky_as_table = true,
  3767. }
  3768. * `minetest.has_feature(arg)`: returns `boolean, missing_features`
  3769. * `arg`: string or table in format `{foo=true, bar=true}`
  3770. * `missing_features`: `{foo=true, bar=true}`
  3771. * `minetest.get_player_information(player_name)`: Table containing information
  3772. about a player. Example return value:
  3773. {
  3774. address = "127.0.0.1", -- IP address of client
  3775. ip_version = 4, -- IPv4 / IPv6
  3776. connection_uptime = 200, -- seconds since client connected
  3777. protocol_version = 32, -- protocol version used by client
  3778. formspec_version = 2, -- supported formspec version
  3779. lang_code = "fr" -- Language code used for translation
  3780. -- the following keys can be missing if no stats have been collected yet
  3781. min_rtt = 0.01, -- minimum round trip time
  3782. max_rtt = 0.2, -- maximum round trip time
  3783. avg_rtt = 0.02, -- average round trip time
  3784. min_jitter = 0.01, -- minimum packet time jitter
  3785. max_jitter = 0.5, -- maximum packet time jitter
  3786. avg_jitter = 0.03, -- average packet time jitter
  3787. -- the following information is available in a debug build only!!!
  3788. -- DO NOT USE IN MODS
  3789. --ser_vers = 26, -- serialization version used by client
  3790. --major = 0, -- major version number
  3791. --minor = 4, -- minor version number
  3792. --patch = 10, -- patch version number
  3793. --vers_string = "0.4.9-git", -- full version string
  3794. --state = "Active" -- current client state
  3795. }
  3796. * `minetest.mkdir(path)`: returns success.
  3797. * Creates a directory specified by `path`, creating parent directories
  3798. if they don't exist.
  3799. * `minetest.rmdir(path, recursive)`: returns success.
  3800. * Removes a directory specified by `path`.
  3801. * If `recursive` is set to `true`, the directory is recursively removed.
  3802. Otherwise, the directory will only be removed if it is empty.
  3803. * Returns true on success, false on failure.
  3804. * `minetest.cpdir(source, destination)`: returns success.
  3805. * Copies a directory specified by `path` to `destination`
  3806. * Any files in `destination` will be overwritten if they already exist.
  3807. * Returns true on success, false on failure.
  3808. * `minetest.mvdir(source, destination)`: returns success.
  3809. * Moves a directory specified by `path` to `destination`.
  3810. * If the `destination` is a non-empty directory, then the move will fail.
  3811. * Returns true on success, false on failure.
  3812. * `minetest.get_dir_list(path, [is_dir])`: returns list of entry names
  3813. * is_dir is one of:
  3814. * nil: return all entries,
  3815. * true: return only subdirectory names, or
  3816. * false: return only file names.
  3817. * `minetest.safe_file_write(path, content)`: returns boolean indicating success
  3818. * Replaces contents of file at path with new contents in a safe (atomic)
  3819. way. Use this instead of below code when writing e.g. database files:
  3820. `local f = io.open(path, "wb"); f:write(content); f:close()`
  3821. * `minetest.get_version()`: returns a table containing components of the
  3822. engine version. Components:
  3823. * `project`: Name of the project, eg, "Minetest"
  3824. * `string`: Simple version, eg, "1.2.3-dev"
  3825. * `hash`: Full git version (only set if available),
  3826. eg, "1.2.3-dev-01234567-dirty".
  3827. Use this for informational purposes only. The information in the returned
  3828. table does not represent the capabilities of the engine, nor is it
  3829. reliable or verifiable. Compatible forks will have a different name and
  3830. version entirely. To check for the presence of engine features, test
  3831. whether the functions exported by the wanted features exist. For example:
  3832. `if minetest.check_for_falling then ... end`.
  3833. * `minetest.sha1(data, [raw])`: returns the sha1 hash of data
  3834. * `data`: string of data to hash
  3835. * `raw`: return raw bytes instead of hex digits, default: false
  3836. * `minetest.colorspec_to_colorstring(colorspec)`: Converts a ColorSpec to a
  3837. ColorString. If the ColorSpec is invalid, returns `nil`.
  3838. * `colorspec`: The ColorSpec to convert
  3839. * `minetest.colorspec_to_bytes(colorspec)`: Converts a ColorSpec to a raw
  3840. string of four bytes in an RGBA layout, returned as a string.
  3841. * `colorspec`: The ColorSpec to convert
  3842. * `minetest.encode_png(width, height, data, [compression])`: Encode a PNG
  3843. image and return it in string form.
  3844. * `width`: Width of the image
  3845. * `height`: Height of the image
  3846. * `data`: Image data, one of:
  3847. * array table of ColorSpec, length must be width*height
  3848. * string with raw RGBA pixels, length must be width*height*4
  3849. * `compression`: Optional zlib compression level, number in range 0 to 9.
  3850. The data is one-dimensional, starting in the upper left corner of the image
  3851. and laid out in scanlines going from left to right, then top to bottom.
  3852. Please note that it's not safe to use string.char to generate raw data,
  3853. use `colorspec_to_bytes` to generate raw RGBA values in a predictable way.
  3854. The resulting PNG image is always 32-bit. Palettes are not supported at the moment.
  3855. You may use this to procedurally generate textures during server init.
  3856. Logging
  3857. -------
  3858. * `minetest.debug(...)`
  3859. * Equivalent to `minetest.log(table.concat({...}, "\t"))`
  3860. * `minetest.log([level,] text)`
  3861. * `level` is one of `"none"`, `"error"`, `"warning"`, `"action"`,
  3862. `"info"`, or `"verbose"`. Default is `"none"`.
  3863. Registration functions
  3864. ----------------------
  3865. Call these functions only at load time!
  3866. ### Environment
  3867. * `minetest.register_node(name, node definition)`
  3868. * `minetest.register_craftitem(name, item definition)`
  3869. * `minetest.register_tool(name, item definition)`
  3870. * `minetest.override_item(name, redefinition)`
  3871. * Overrides fields of an item registered with register_node/tool/craftitem.
  3872. * Note: Item must already be defined, (opt)depend on the mod defining it.
  3873. * Example: `minetest.override_item("default:mese",
  3874. {light_source=minetest.LIGHT_MAX})`
  3875. * `minetest.unregister_item(name)`
  3876. * Unregisters the item from the engine, and deletes the entry with key
  3877. `name` from `minetest.registered_items` and from the associated item table
  3878. according to its nature: `minetest.registered_nodes`, etc.
  3879. * `minetest.register_entity(name, entity definition)`
  3880. * `minetest.register_abm(abm definition)`
  3881. * `minetest.register_lbm(lbm definition)`
  3882. * `minetest.register_alias(alias, original_name)`
  3883. * Also use this to set the 'mapgen aliases' needed in a game for the core
  3884. mapgens. See [Mapgen aliases] section above.
  3885. * `minetest.register_alias_force(alias, original_name)`
  3886. * `minetest.register_ore(ore definition)`
  3887. * Returns an integer object handle uniquely identifying the registered
  3888. ore on success.
  3889. * The order of ore registrations determines the order of ore generation.
  3890. * `minetest.register_biome(biome definition)`
  3891. * Returns an integer object handle uniquely identifying the registered
  3892. biome on success. To get the biome ID, use `minetest.get_biome_id`.
  3893. * `minetest.unregister_biome(name)`
  3894. * Unregisters the biome from the engine, and deletes the entry with key
  3895. `name` from `minetest.registered_biomes`.
  3896. * Warning: This alters the biome to biome ID correspondences, so any
  3897. decorations or ores using the 'biomes' field must afterwards be cleared
  3898. and re-registered.
  3899. * `minetest.register_decoration(decoration definition)`
  3900. * Returns an integer object handle uniquely identifying the registered
  3901. decoration on success. To get the decoration ID, use
  3902. `minetest.get_decoration_id`.
  3903. * The order of decoration registrations determines the order of decoration
  3904. generation.
  3905. * `minetest.register_schematic(schematic definition)`
  3906. * Returns an integer object handle uniquely identifying the registered
  3907. schematic on success.
  3908. * If the schematic is loaded from a file, the `name` field is set to the
  3909. filename.
  3910. * If the function is called when loading the mod, and `name` is a relative
  3911. path, then the current mod path will be prepended to the schematic
  3912. filename.
  3913. * `minetest.clear_registered_biomes()`
  3914. * Clears all biomes currently registered.
  3915. * Warning: Clearing and re-registering biomes alters the biome to biome ID
  3916. correspondences, so any decorations or ores using the 'biomes' field must
  3917. afterwards be cleared and re-registered.
  3918. * `minetest.clear_registered_decorations()`
  3919. * Clears all decorations currently registered.
  3920. * `minetest.clear_registered_ores()`
  3921. * Clears all ores currently registered.
  3922. * `minetest.clear_registered_schematics()`
  3923. * Clears all schematics currently registered.
  3924. ### Gameplay
  3925. * `minetest.register_craft(recipe)`
  3926. * Check recipe table syntax for different types below.
  3927. * `minetest.clear_craft(recipe)`
  3928. * Will erase existing craft based either on output item or on input recipe.
  3929. * Specify either output or input only. If you specify both, input will be
  3930. ignored. For input use the same recipe table syntax as for
  3931. `minetest.register_craft(recipe)`. For output specify only the item,
  3932. without a quantity.
  3933. * Returns false if no erase candidate could be found, otherwise returns true.
  3934. * **Warning**! The type field ("shaped", "cooking" or any other) will be
  3935. ignored if the recipe contains output. Erasing is then done independently
  3936. from the crafting method.
  3937. * `minetest.register_chatcommand(cmd, chatcommand definition)`
  3938. * `minetest.override_chatcommand(name, redefinition)`
  3939. * Overrides fields of a chatcommand registered with `register_chatcommand`.
  3940. * `minetest.unregister_chatcommand(name)`
  3941. * Unregisters a chatcommands registered with `register_chatcommand`.
  3942. * `minetest.register_privilege(name, definition)`
  3943. * `definition` can be a description or a definition table (see [Privilege
  3944. definition]).
  3945. * If it is a description, the priv will be granted to singleplayer and admin
  3946. by default.
  3947. * To allow players with `basic_privs` to grant, see the `basic_privs`
  3948. minetest.conf setting.
  3949. * `minetest.register_authentication_handler(authentication handler definition)`
  3950. * Registers an auth handler that overrides the builtin one.
  3951. * This function can be called by a single mod once only.
  3952. Global callback registration functions
  3953. --------------------------------------
  3954. Call these functions only at load time!
  3955. * `minetest.register_globalstep(function(dtime))`
  3956. * Called every server step, usually interval of 0.1s
  3957. * `minetest.register_on_mods_loaded(function())`
  3958. * Called after mods have finished loading and before the media is cached or the
  3959. aliases handled.
  3960. * `minetest.register_on_shutdown(function())`
  3961. * Called before server shutdown
  3962. * **Warning**: If the server terminates abnormally (i.e. crashes), the
  3963. registered callbacks **will likely not be run**. Data should be saved at
  3964. semi-frequent intervals as well as on server shutdown.
  3965. * `minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing))`
  3966. * Called when a node has been placed
  3967. * If return `true` no item is taken from `itemstack`
  3968. * `placer` may be any valid ObjectRef or nil.
  3969. * **Not recommended**; use `on_construct` or `after_place_node` in node
  3970. definition whenever possible.
  3971. * `minetest.register_on_dignode(function(pos, oldnode, digger))`
  3972. * Called when a node has been dug.
  3973. * **Not recommended**; Use `on_destruct` or `after_dig_node` in node
  3974. definition whenever possible.
  3975. * `minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing))`
  3976. * Called when a node is punched
  3977. * `minetest.register_on_generated(function(minp, maxp, blockseed))`
  3978. * Called after generating a piece of world. Modifying nodes inside the area
  3979. is a bit faster than usual.
  3980. * `minetest.register_on_newplayer(function(ObjectRef))`
  3981. * Called when a new player enters the world for the first time
  3982. * `minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage))`
  3983. * Called when a player is punched
  3984. * Note: This callback is invoked even if the punched player is dead.
  3985. * `player`: ObjectRef - Player that was punched
  3986. * `hitter`: ObjectRef - Player that hit
  3987. * `time_from_last_punch`: Meant for disallowing spamming of clicks
  3988. (can be nil).
  3989. * `tool_capabilities`: Capability table of used item (can be nil)
  3990. * `dir`: Unit vector of direction of punch. Always defined. Points from
  3991. the puncher to the punched.
  3992. * `damage`: Number that represents the damage calculated by the engine
  3993. * should return `true` to prevent the default damage mechanism
  3994. * `minetest.register_on_rightclickplayer(function(player, clicker))`
  3995. * Called when the 'place/use' key was used while pointing a player
  3996. (not neccessarily an actual rightclick)
  3997. * `player`: ObjectRef - Player that is acted upon
  3998. * `clicker`: ObjectRef - Object that acted upon `player`, may or may not be a player
  3999. * `minetest.register_on_player_hpchange(function(player, hp_change, reason), modifier)`
  4000. * Called when the player gets damaged or healed
  4001. * `player`: ObjectRef of the player
  4002. * `hp_change`: the amount of change. Negative when it is damage.
  4003. * `reason`: a PlayerHPChangeReason table.
  4004. * The `type` field will have one of the following values:
  4005. * `set_hp`: A mod or the engine called `set_hp` without
  4006. giving a type - use this for custom damage types.
  4007. * `punch`: Was punched. `reason.object` will hold the puncher, or nil if none.
  4008. * `fall`
  4009. * `node_damage`: `damage_per_second` from a neighbouring node.
  4010. `reason.node` will hold the node name or nil.
  4011. * `drown`
  4012. * `respawn`
  4013. * Any of the above types may have additional fields from mods.
  4014. * `reason.from` will be `mod` or `engine`.
  4015. * `modifier`: when true, the function should return the actual `hp_change`.
  4016. Note: modifiers only get a temporary `hp_change` that can be modified by later modifiers.
  4017. Modifiers can return true as a second argument to stop the execution of further functions.
  4018. Non-modifiers receive the final HP change calculated by the modifiers.
  4019. * `minetest.register_on_dieplayer(function(ObjectRef, reason))`
  4020. * Called when a player dies
  4021. * `reason`: a PlayerHPChangeReason table, see register_on_player_hpchange
  4022. * `minetest.register_on_respawnplayer(function(ObjectRef))`
  4023. * Called when player is to be respawned
  4024. * Called _before_ repositioning of player occurs
  4025. * return true in func to disable regular player placement
  4026. * `minetest.register_on_prejoinplayer(function(name, ip))`
  4027. * Called when a client connects to the server, prior to authentication
  4028. * If it returns a string, the client is disconnected with that string as
  4029. reason.
  4030. * `minetest.register_on_joinplayer(function(ObjectRef, last_login))`
  4031. * Called when a player joins the game
  4032. * `last_login`: The timestamp of the previous login, or nil if player is new
  4033. * `minetest.register_on_leaveplayer(function(ObjectRef, timed_out))`
  4034. * Called when a player leaves the game
  4035. * `timed_out`: True for timeout, false for other reasons.
  4036. * `minetest.register_on_authplayer(function(name, ip, is_success))`
  4037. * Called when a client attempts to log into an account.
  4038. * `name`: The name of the account being authenticated.
  4039. * `ip`: The IP address of the client
  4040. * `is_success`: Whether the client was successfully authenticated
  4041. * For newly registered accounts, `is_success` will always be true
  4042. * `minetest.register_on_auth_fail(function(name, ip))`
  4043. * Deprecated: use `minetest.register_on_authplayer(name, ip, is_success)` instead.
  4044. * `minetest.register_on_cheat(function(ObjectRef, cheat))`
  4045. * Called when a player cheats
  4046. * `cheat`: `{type=<cheat_type>}`, where `<cheat_type>` is one of:
  4047. * `moved_too_fast`
  4048. * `interacted_too_far`
  4049. * `interacted_with_self`
  4050. * `interacted_while_dead`
  4051. * `finished_unknown_dig`
  4052. * `dug_unbreakable`
  4053. * `dug_too_fast`
  4054. * `minetest.register_on_chat_message(function(name, message))`
  4055. * Called always when a player says something
  4056. * Return `true` to mark the message as handled, which means that it will
  4057. not be sent to other players.
  4058. * `minetest.register_on_chatcommand(function(name, command, params))`
  4059. * Called always when a chatcommand is triggered, before `minetest.registered_chatcommands`
  4060. is checked to see if the command exists, but after the input is parsed.
  4061. * Return `true` to mark the command as handled, which means that the default
  4062. handlers will be prevented.
  4063. * `minetest.register_on_player_receive_fields(function(player, formname, fields))`
  4064. * Called when the server received input from `player` in a formspec with
  4065. the given `formname`. Specifically, this is called on any of the
  4066. following events:
  4067. * a button was pressed,
  4068. * Enter was pressed while the focus was on a text field
  4069. * a checkbox was toggled,
  4070. * something was selected in a dropdown list,
  4071. * a different tab was selected,
  4072. * selection was changed in a textlist or table,
  4073. * an entry was double-clicked in a textlist or table,
  4074. * a scrollbar was moved, or
  4075. * the form was actively closed by the player.
  4076. * Fields are sent for formspec elements which define a field. `fields`
  4077. is a table containing each formspecs element value (as string), with
  4078. the `name` parameter as index for each. The value depends on the
  4079. formspec element type:
  4080. * `animated_image`: Returns the index of the current frame.
  4081. * `button` and variants: If pressed, contains the user-facing button
  4082. text as value. If not pressed, is `nil`
  4083. * `field`, `textarea` and variants: Text in the field
  4084. * `dropdown`: Either the index or value, depending on the `index event`
  4085. dropdown argument.
  4086. * `tabheader`: Tab index, starting with `"1"` (only if tab changed)
  4087. * `checkbox`: `"true"` if checked, `"false"` if unchecked
  4088. * `textlist`: See `minetest.explode_textlist_event`
  4089. * `table`: See `minetest.explode_table_event`
  4090. * `scrollbar`: See `minetest.explode_scrollbar_event`
  4091. * Special case: `["quit"]="true"` is sent when the user actively
  4092. closed the form by mouse click, keypress or through a button_exit[]
  4093. element.
  4094. * Special case: `["key_enter"]="true"` is sent when the user pressed
  4095. the Enter key and the focus was either nowhere (causing the formspec
  4096. to be closed) or on a button. If the focus was on a text field,
  4097. additionally, the index `key_enter_field` contains the name of the
  4098. text field. See also: `field_close_on_enter`.
  4099. * Newest functions are called first
  4100. * If function returns `true`, remaining functions are not called
  4101. * `minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv))`
  4102. * Called when `player` crafts something
  4103. * `itemstack` is the output
  4104. * `old_craft_grid` contains the recipe (Note: the one in the inventory is
  4105. cleared).
  4106. * `craft_inv` is the inventory with the crafting grid
  4107. * Return either an `ItemStack`, to replace the output, or `nil`, to not
  4108. modify it.
  4109. * `minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv))`
  4110. * The same as before, except that it is called before the player crafts, to
  4111. make craft prediction, and it should not change anything.
  4112. * `minetest.register_allow_player_inventory_action(function(player, action, inventory, inventory_info))`
  4113. * Determines how much of a stack may be taken, put or moved to a
  4114. player inventory.
  4115. * `player` (type `ObjectRef`) is the player who modified the inventory
  4116. `inventory` (type `InvRef`).
  4117. * List of possible `action` (string) values and their
  4118. `inventory_info` (table) contents:
  4119. * `move`: `{from_list=string, to_list=string, from_index=number, to_index=number, count=number}`
  4120. * `put`: `{listname=string, index=number, stack=ItemStack}`
  4121. * `take`: Same as `put`
  4122. * Return a numeric value to limit the amount of items to be taken, put or
  4123. moved. A value of `-1` for `take` will make the source stack infinite.
  4124. * `minetest.register_on_player_inventory_action(function(player, action, inventory, inventory_info))`
  4125. * Called after a take, put or move event from/to/in a player inventory
  4126. * Function arguments: see `minetest.register_allow_player_inventory_action`
  4127. * Does not accept or handle any return value.
  4128. * `minetest.register_on_protection_violation(function(pos, name))`
  4129. * Called by `builtin` and mods when a player violates protection at a
  4130. position (eg, digs a node or punches a protected entity).
  4131. * The registered functions can be called using
  4132. `minetest.record_protection_violation`.
  4133. * The provided function should check that the position is protected by the
  4134. mod calling this function before it prints a message, if it does, to
  4135. allow for multiple protection mods.
  4136. * `minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, user, pointed_thing))`
  4137. * Called when an item is eaten, by `minetest.item_eat`
  4138. * Return `itemstack` to cancel the default item eat response (i.e.: hp increase).
  4139. * `minetest.register_on_priv_grant(function(name, granter, priv))`
  4140. * Called when `granter` grants the priv `priv` to `name`.
  4141. * Note that the callback will be called twice if it's done by a player,
  4142. once with granter being the player name, and again with granter being nil.
  4143. * `minetest.register_on_priv_revoke(function(name, revoker, priv))`
  4144. * Called when `revoker` revokes the priv `priv` from `name`.
  4145. * Note that the callback will be called twice if it's done by a player,
  4146. once with revoker being the player name, and again with revoker being nil.
  4147. * `minetest.register_can_bypass_userlimit(function(name, ip))`
  4148. * Called when `name` user connects with `ip`.
  4149. * Return `true` to by pass the player limit
  4150. * `minetest.register_on_modchannel_message(function(channel_name, sender, message))`
  4151. * Called when an incoming mod channel message is received
  4152. * You should have joined some channels to receive events.
  4153. * If message comes from a server mod, `sender` field is an empty string.
  4154. * `minetest.register_on_liquid_transformed(function(pos_list, node_list))`
  4155. * Called after liquid nodes (`liquidtype ~= "none"`) are modified by the
  4156. engine's liquid transformation process.
  4157. * `pos_list` is an array of all modified positions.
  4158. * `node_list` is an array of the old node that was previously at the position
  4159. with the corresponding index in pos_list.
  4160. Setting-related
  4161. ---------------
  4162. * `minetest.settings`: Settings object containing all of the settings from the
  4163. main config file (`minetest.conf`).
  4164. * `minetest.setting_get_pos(name)`: Loads a setting from the main settings and
  4165. parses it as a position (in the format `(1,2,3)`). Returns a position or nil.
  4166. Authentication
  4167. --------------
  4168. * `minetest.string_to_privs(str[, delim])`:
  4169. * Converts string representation of privs into table form
  4170. * `delim`: String separating the privs. Defaults to `","`.
  4171. * Returns `{ priv1 = true, ... }`
  4172. * `minetest.privs_to_string(privs[, delim])`:
  4173. * Returns the string representation of `privs`
  4174. * `delim`: String to delimit privs. Defaults to `","`.
  4175. * `minetest.get_player_privs(name) -> {priv1=true,...}`
  4176. * `minetest.check_player_privs(player_or_name, ...)`:
  4177. returns `bool, missing_privs`
  4178. * A quickhand for checking privileges.
  4179. * `player_or_name`: Either a Player object or the name of a player.
  4180. * `...` is either a list of strings, e.g. `"priva", "privb"` or
  4181. a table, e.g. `{ priva = true, privb = true }`.
  4182. * `minetest.check_password_entry(name, entry, password)`
  4183. * Returns true if the "password entry" for a player with name matches given
  4184. password, false otherwise.
  4185. * The "password entry" is the password representation generated by the
  4186. engine as returned as part of a `get_auth()` call on the auth handler.
  4187. * Only use this function for making it possible to log in via password from
  4188. external protocols such as IRC, other uses are frowned upon.
  4189. * `minetest.get_password_hash(name, raw_password)`
  4190. * Convert a name-password pair to a password hash that Minetest can use.
  4191. * The returned value alone is not a good basis for password checks based
  4192. on comparing the password hash in the database with the password hash
  4193. from the function, with an externally provided password, as the hash
  4194. in the db might use the new SRP verifier format.
  4195. * For this purpose, use `minetest.check_password_entry` instead.
  4196. * `minetest.get_player_ip(name)`: returns an IP address string for the player
  4197. `name`.
  4198. * The player needs to be online for this to be successful.
  4199. * `minetest.get_auth_handler()`: Return the currently active auth handler
  4200. * See the [Authentication handler definition]
  4201. * Use this to e.g. get the authentication data for a player:
  4202. `local auth_data = minetest.get_auth_handler().get_auth(playername)`
  4203. * `minetest.notify_authentication_modified(name)`
  4204. * Must be called by the authentication handler for privilege changes.
  4205. * `name`: string; if omitted, all auth data should be considered modified
  4206. * `minetest.set_player_password(name, password_hash)`: Set password hash of
  4207. player `name`.
  4208. * `minetest.set_player_privs(name, {priv1=true,...})`: Set privileges of player
  4209. `name`.
  4210. * `minetest.auth_reload()`
  4211. * See `reload()` in authentication handler definition
  4212. `minetest.set_player_password`, `minetest.set_player_privs`,
  4213. `minetest.get_player_privs` and `minetest.auth_reload` call the authentication
  4214. handler.
  4215. Chat
  4216. ----
  4217. * `minetest.chat_send_all(text)`
  4218. * `minetest.chat_send_player(name, text)`
  4219. * `minetest.format_chat_message(name, message)`
  4220. * Used by the server to format a chat message, based on the setting `chat_message_format`.
  4221. Refer to the documentation of the setting for a list of valid placeholders.
  4222. * Takes player name and message, and returns the formatted string to be sent to players.
  4223. * Can be redefined by mods if required, for things like colored names or messages.
  4224. * **Only** the first occurrence of each placeholder will be replaced.
  4225. Environment access
  4226. ------------------
  4227. * `minetest.set_node(pos, node)`
  4228. * `minetest.add_node(pos, node)`: alias to `minetest.set_node`
  4229. * Set node at position `pos`
  4230. * `node`: table `{name=string, param1=number, param2=number}`
  4231. * If param1 or param2 is omitted, it's set to `0`.
  4232. * e.g. `minetest.set_node({x=0, y=10, z=0}, {name="default:wood"})`
  4233. * `minetest.bulk_set_node({pos1, pos2, pos3, ...}, node)`
  4234. * Set node on all positions set in the first argument.
  4235. * e.g. `minetest.bulk_set_node({{x=0, y=1, z=1}, {x=1, y=2, z=2}}, {name="default:stone"})`
  4236. * For node specification or position syntax see `minetest.set_node` call
  4237. * Faster than set_node due to single call, but still considerably slower
  4238. than Lua Voxel Manipulators (LVM) for large numbers of nodes.
  4239. Unlike LVMs, this will call node callbacks. It also allows setting nodes
  4240. in spread out positions which would cause LVMs to waste memory.
  4241. For setting a cube, this is 1.3x faster than set_node whereas LVM is 20
  4242. times faster.
  4243. * `minetest.swap_node(pos, node)`
  4244. * Set node at position, but don't remove metadata
  4245. * `minetest.remove_node(pos)`
  4246. * By default it does the same as `minetest.set_node(pos, {name="air"})`
  4247. * `minetest.get_node(pos)`
  4248. * Returns the node at the given position as table in the format
  4249. `{name="node_name", param1=0, param2=0}`,
  4250. returns `{name="ignore", param1=0, param2=0}` for unloaded areas.
  4251. * `minetest.get_node_or_nil(pos)`
  4252. * Same as `get_node` but returns `nil` for unloaded areas.
  4253. * `minetest.get_node_light(pos, timeofday)`
  4254. * Gets the light value at the given position. Note that the light value
  4255. "inside" the node at the given position is returned, so you usually want
  4256. to get the light value of a neighbor.
  4257. * `pos`: The position where to measure the light.
  4258. * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
  4259. * Returns a number between `0` and `15` or `nil`
  4260. * `nil` is returned e.g. when the map isn't loaded at `pos`
  4261. * `minetest.get_natural_light(pos[, timeofday])`
  4262. * Figures out the sunlight (or moonlight) value at pos at the given time of
  4263. day.
  4264. * `pos`: The position of the node
  4265. * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
  4266. * Returns a number between `0` and `15` or `nil`
  4267. * This function tests 203 nodes in the worst case, which happens very
  4268. unlikely
  4269. * `minetest.get_artificial_light(param1)`
  4270. * Calculates the artificial light (light from e.g. torches) value from the
  4271. `param1` value.
  4272. * `param1`: The param1 value of a `paramtype = "light"` node.
  4273. * Returns a number between `0` and `15`
  4274. * Currently it's the same as `math.floor(param1 / 16)`, except that it
  4275. ensures compatibility.
  4276. * `minetest.place_node(pos, node)`
  4277. * Place node with the same effects that a player would cause
  4278. * `minetest.dig_node(pos)`
  4279. * Dig node with the same effects that a player would cause
  4280. * Returns `true` if successful, `false` on failure (e.g. protected location)
  4281. * `minetest.punch_node(pos)`
  4282. * Punch node with the same effects that a player would cause
  4283. * `minetest.spawn_falling_node(pos)`
  4284. * Change node into falling node
  4285. * Returns `true` and the ObjectRef of the spawned entity if successful, `false` on failure
  4286. * `minetest.find_nodes_with_meta(pos1, pos2)`
  4287. * Get a table of positions of nodes that have metadata within a region
  4288. {pos1, pos2}.
  4289. * `minetest.get_meta(pos)`
  4290. * Get a `NodeMetaRef` at that position
  4291. * `minetest.get_node_timer(pos)`
  4292. * Get `NodeTimerRef`
  4293. * `minetest.add_entity(pos, name, [staticdata])`: Spawn Lua-defined entity at
  4294. position.
  4295. * Returns `ObjectRef`, or `nil` if failed
  4296. * `minetest.add_item(pos, item)`: Spawn item
  4297. * Returns `ObjectRef`, or `nil` if failed
  4298. * `minetest.get_player_by_name(name)`: Get an `ObjectRef` to a player
  4299. * `minetest.get_objects_inside_radius(pos, radius)`: returns a list of
  4300. ObjectRefs.
  4301. * `radius`: using an euclidean metric
  4302. * `minetest.get_objects_in_area(pos1, pos2)`: returns a list of
  4303. ObjectRefs.
  4304. * `pos1` and `pos2` are the min and max positions of the area to search.
  4305. * `minetest.set_timeofday(val)`
  4306. * `val` is between `0` and `1`; `0` for midnight, `0.5` for midday
  4307. * `minetest.get_timeofday()`
  4308. * `minetest.get_gametime()`: returns the time, in seconds, since the world was
  4309. created.
  4310. * `minetest.get_day_count()`: returns number days elapsed since world was
  4311. created.
  4312. * accounts for time changes.
  4313. * `minetest.find_node_near(pos, radius, nodenames, [search_center])`: returns
  4314. pos or `nil`.
  4315. * `radius`: using a maximum metric
  4316. * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
  4317. * `search_center` is an optional boolean (default: `false`)
  4318. If true `pos` is also checked for the nodes
  4319. * `minetest.find_nodes_in_area(pos1, pos2, nodenames, [grouped])`
  4320. * `pos1` and `pos2` are the min and max positions of the area to search.
  4321. * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
  4322. * If `grouped` is true the return value is a table indexed by node name
  4323. which contains lists of positions.
  4324. * If `grouped` is false or absent the return values are as follows:
  4325. first value: Table with all node positions
  4326. second value: Table with the count of each node with the node name
  4327. as index
  4328. * Area volume is limited to 4,096,000 nodes
  4329. * `minetest.find_nodes_in_area_under_air(pos1, pos2, nodenames)`: returns a
  4330. list of positions.
  4331. * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
  4332. * Return value: Table with all node positions with a node air above
  4333. * Area volume is limited to 4,096,000 nodes
  4334. * `minetest.get_perlin(noiseparams)`
  4335. * Return world-specific perlin noise.
  4336. * The actual seed used is the noiseparams seed plus the world seed.
  4337. * `minetest.get_perlin(seeddiff, octaves, persistence, spread)`
  4338. * Deprecated: use `minetest.get_perlin(noiseparams)` instead.
  4339. * Return world-specific perlin noise.
  4340. * `minetest.get_voxel_manip([pos1, pos2])`
  4341. * Return voxel manipulator object.
  4342. * Loads the manipulator from the map if positions are passed.
  4343. * `minetest.set_gen_notify(flags, {deco_ids})`
  4344. * Set the types of on-generate notifications that should be collected.
  4345. * `flags` is a flag field with the available flags:
  4346. * dungeon
  4347. * temple
  4348. * cave_begin
  4349. * cave_end
  4350. * large_cave_begin
  4351. * large_cave_end
  4352. * decoration
  4353. * The second parameter is a list of IDs of decorations which notification
  4354. is requested for.
  4355. * `minetest.get_gen_notify()`
  4356. * Returns a flagstring and a table with the `deco_id`s.
  4357. * `minetest.get_decoration_id(decoration_name)`
  4358. * Returns the decoration ID number for the provided decoration name string,
  4359. or `nil` on failure.
  4360. * `minetest.get_mapgen_object(objectname)`
  4361. * Return requested mapgen object if available (see [Mapgen objects])
  4362. * `minetest.get_heat(pos)`
  4363. * Returns the heat at the position, or `nil` on failure.
  4364. * `minetest.get_humidity(pos)`
  4365. * Returns the humidity at the position, or `nil` on failure.
  4366. * `minetest.get_biome_data(pos)`
  4367. * Returns a table containing:
  4368. * `biome` the biome id of the biome at that position
  4369. * `heat` the heat at the position
  4370. * `humidity` the humidity at the position
  4371. * Or returns `nil` on failure.
  4372. * `minetest.get_biome_id(biome_name)`
  4373. * Returns the biome id, as used in the biomemap Mapgen object and returned
  4374. by `minetest.get_biome_data(pos)`, for a given biome_name string.
  4375. * `minetest.get_biome_name(biome_id)`
  4376. * Returns the biome name string for the provided biome id, or `nil` on
  4377. failure.
  4378. * If no biomes have been registered, such as in mgv6, returns `default`.
  4379. * `minetest.get_mapgen_params()`
  4380. * Deprecated: use `minetest.get_mapgen_setting(name)` instead.
  4381. * Returns a table containing:
  4382. * `mgname`
  4383. * `seed`
  4384. * `chunksize`
  4385. * `water_level`
  4386. * `flags`
  4387. * `minetest.set_mapgen_params(MapgenParams)`
  4388. * Deprecated: use `minetest.set_mapgen_setting(name, value, override)`
  4389. instead.
  4390. * Set map generation parameters.
  4391. * Function cannot be called after the registration period.
  4392. * Takes a table as an argument with the fields:
  4393. * `mgname`
  4394. * `seed`
  4395. * `chunksize`
  4396. * `water_level`
  4397. * `flags`
  4398. * Leave field unset to leave that parameter unchanged.
  4399. * `flags` contains a comma-delimited string of flags to set, or if the
  4400. prefix `"no"` is attached, clears instead.
  4401. * `flags` is in the same format and has the same options as `mg_flags` in
  4402. `minetest.conf`.
  4403. * `minetest.get_mapgen_setting(name)`
  4404. * Gets the *active* mapgen setting (or nil if none exists) in string
  4405. format with the following order of precedence:
  4406. 1) Settings loaded from map_meta.txt or overrides set during mod
  4407. execution.
  4408. 2) Settings set by mods without a metafile override
  4409. 3) Settings explicitly set in the user config file, minetest.conf
  4410. 4) Settings set as the user config default
  4411. * `minetest.get_mapgen_setting_noiseparams(name)`
  4412. * Same as above, but returns the value as a NoiseParams table if the
  4413. setting `name` exists and is a valid NoiseParams.
  4414. * `minetest.set_mapgen_setting(name, value, [override_meta])`
  4415. * Sets a mapgen param to `value`, and will take effect if the corresponding
  4416. mapgen setting is not already present in map_meta.txt.
  4417. * `override_meta` is an optional boolean (default: `false`). If this is set
  4418. to true, the setting will become the active setting regardless of the map
  4419. metafile contents.
  4420. * Note: to set the seed, use `"seed"`, not `"fixed_map_seed"`.
  4421. * `minetest.set_mapgen_setting_noiseparams(name, value, [override_meta])`
  4422. * Same as above, except value is a NoiseParams table.
  4423. * `minetest.set_noiseparams(name, noiseparams, set_default)`
  4424. * Sets the noiseparams setting of `name` to the noiseparams table specified
  4425. in `noiseparams`.
  4426. * `set_default` is an optional boolean (default: `true`) that specifies
  4427. whether the setting should be applied to the default config or current
  4428. active config.
  4429. * `minetest.get_noiseparams(name)`
  4430. * Returns a table of the noiseparams for name.
  4431. * `minetest.generate_ores(vm, pos1, pos2)`
  4432. * Generate all registered ores within the VoxelManip `vm` and in the area
  4433. from `pos1` to `pos2`.
  4434. * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
  4435. * `minetest.generate_decorations(vm, pos1, pos2)`
  4436. * Generate all registered decorations within the VoxelManip `vm` and in the
  4437. area from `pos1` to `pos2`.
  4438. * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
  4439. * `minetest.clear_objects([options])`
  4440. * Clear all objects in the environment
  4441. * Takes an optional table as an argument with the field `mode`.
  4442. * mode = `"full"` : Load and go through every mapblock, clearing
  4443. objects (default).
  4444. * mode = `"quick"`: Clear objects immediately in loaded mapblocks,
  4445. clear objects in unloaded mapblocks only when the
  4446. mapblocks are next activated.
  4447. * `minetest.load_area(pos1[, pos2])`
  4448. * Load the mapblocks containing the area from `pos1` to `pos2`.
  4449. `pos2` defaults to `pos1` if not specified.
  4450. * This function does not trigger map generation.
  4451. * `minetest.emerge_area(pos1, pos2, [callback], [param])`
  4452. * Queue all blocks in the area from `pos1` to `pos2`, inclusive, to be
  4453. asynchronously fetched from memory, loaded from disk, or if inexistent,
  4454. generates them.
  4455. * If `callback` is a valid Lua function, this will be called for each block
  4456. emerged.
  4457. * The function signature of callback is:
  4458. `function EmergeAreaCallback(blockpos, action, calls_remaining, param)`
  4459. * `blockpos` is the *block* coordinates of the block that had been
  4460. emerged.
  4461. * `action` could be one of the following constant values:
  4462. * `minetest.EMERGE_CANCELLED`
  4463. * `minetest.EMERGE_ERRORED`
  4464. * `minetest.EMERGE_FROM_MEMORY`
  4465. * `minetest.EMERGE_FROM_DISK`
  4466. * `minetest.EMERGE_GENERATED`
  4467. * `calls_remaining` is the number of callbacks to be expected after
  4468. this one.
  4469. * `param` is the user-defined parameter passed to emerge_area (or
  4470. nil if the parameter was absent).
  4471. * `minetest.delete_area(pos1, pos2)`
  4472. * delete all mapblocks in the area from pos1 to pos2, inclusive
  4473. * `minetest.line_of_sight(pos1, pos2)`: returns `boolean, pos`
  4474. * Checks if there is anything other than air between pos1 and pos2.
  4475. * Returns false if something is blocking the sight.
  4476. * Returns the position of the blocking node when `false`
  4477. * `pos1`: First position
  4478. * `pos2`: Second position
  4479. * `minetest.raycast(pos1, pos2, objects, liquids)`: returns `Raycast`
  4480. * Creates a `Raycast` object.
  4481. * `pos1`: start of the ray
  4482. * `pos2`: end of the ray
  4483. * `objects`: if false, only nodes will be returned. Default is `true`.
  4484. * `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
  4485. returned. Default is `false`.
  4486. * `minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)`
  4487. * returns table containing path that can be walked on
  4488. * returns a table of 3D points representing a path from `pos1` to `pos2` or
  4489. `nil` on failure.
  4490. * Reasons for failure:
  4491. * No path exists at all
  4492. * No path exists within `searchdistance` (see below)
  4493. * Start or end pos is buried in land
  4494. * `pos1`: start position
  4495. * `pos2`: end position
  4496. * `searchdistance`: maximum distance from the search positions to search in.
  4497. In detail: Path must be completely inside a cuboid. The minimum
  4498. `searchdistance` of 1 will confine search between `pos1` and `pos2`.
  4499. Larger values will increase the size of this cuboid in all directions
  4500. * `max_jump`: maximum height difference to consider walkable
  4501. * `max_drop`: maximum height difference to consider droppable
  4502. * `algorithm`: One of `"A*_noprefetch"` (default), `"A*"`, `"Dijkstra"`.
  4503. Difference between `"A*"` and `"A*_noprefetch"` is that
  4504. `"A*"` will pre-calculate the cost-data, the other will calculate it
  4505. on-the-fly
  4506. * `minetest.spawn_tree (pos, {treedef})`
  4507. * spawns L-system tree at given `pos` with definition in `treedef` table
  4508. * `minetest.transforming_liquid_add(pos)`
  4509. * add node to liquid flow update queue
  4510. * `minetest.get_node_max_level(pos)`
  4511. * get max available level for leveled node
  4512. * `minetest.get_node_level(pos)`
  4513. * get level of leveled node (water, snow)
  4514. * `minetest.set_node_level(pos, level)`
  4515. * set level of leveled node, default `level` equals `1`
  4516. * if `totallevel > maxlevel`, returns rest (`total-max`).
  4517. * `minetest.add_node_level(pos, level)`
  4518. * increase level of leveled node by level, default `level` equals `1`
  4519. * if `totallevel > maxlevel`, returns rest (`total-max`)
  4520. * `level` must be between -127 and 127
  4521. * `minetest.fix_light(pos1, pos2)`: returns `true`/`false`
  4522. * resets the light in a cuboid-shaped part of
  4523. the map and removes lighting bugs.
  4524. * Loads the area if it is not loaded.
  4525. * `pos1` is the corner of the cuboid with the least coordinates
  4526. (in node coordinates), inclusive.
  4527. * `pos2` is the opposite corner of the cuboid, inclusive.
  4528. * The actual updated cuboid might be larger than the specified one,
  4529. because only whole map blocks can be updated.
  4530. The actual updated area consists of those map blocks that intersect
  4531. with the given cuboid.
  4532. * However, the neighborhood of the updated area might change
  4533. as well, as light can spread out of the cuboid, also light
  4534. might be removed.
  4535. * returns `false` if the area is not fully generated,
  4536. `true` otherwise
  4537. * `minetest.check_single_for_falling(pos)`
  4538. * causes an unsupported `group:falling_node` node to fall and causes an
  4539. unattached `group:attached_node` node to fall.
  4540. * does not spread these updates to neighbours.
  4541. * `minetest.check_for_falling(pos)`
  4542. * causes an unsupported `group:falling_node` node to fall and causes an
  4543. unattached `group:attached_node` node to fall.
  4544. * spread these updates to neighbours and can cause a cascade
  4545. of nodes to fall.
  4546. * `minetest.get_spawn_level(x, z)`
  4547. * Returns a player spawn y co-ordinate for the provided (x, z)
  4548. co-ordinates, or `nil` for an unsuitable spawn point.
  4549. * For most mapgens a 'suitable spawn point' is one with y between
  4550. `water_level` and `water_level + 16`, and in mgv7 well away from rivers,
  4551. so `nil` will be returned for many (x, z) co-ordinates.
  4552. * The spawn level returned is for a player spawn in unmodified terrain.
  4553. * The spawn level is intentionally above terrain level to cope with
  4554. full-node biome 'dust' nodes.
  4555. Mod channels
  4556. ------------
  4557. You can find mod channels communication scheme in `doc/mod_channels.png`.
  4558. * `minetest.mod_channel_join(channel_name)`
  4559. * Server joins channel `channel_name`, and creates it if necessary. You
  4560. should listen for incoming messages with
  4561. `minetest.register_on_modchannel_message`
  4562. Inventory
  4563. ---------
  4564. `minetest.get_inventory(location)`: returns an `InvRef`
  4565. * `location` = e.g.
  4566. * `{type="player", name="celeron55"}`
  4567. * `{type="node", pos={x=, y=, z=}}`
  4568. * `{type="detached", name="creative"}`
  4569. * `minetest.create_detached_inventory(name, callbacks, [player_name])`: returns
  4570. an `InvRef`.
  4571. * `callbacks`: See [Detached inventory callbacks]
  4572. * `player_name`: Make detached inventory available to one player
  4573. exclusively, by default they will be sent to every player (even if not
  4574. used).
  4575. Note that this parameter is mostly just a workaround and will be removed
  4576. in future releases.
  4577. * Creates a detached inventory. If it already exists, it is cleared.
  4578. * `minetest.remove_detached_inventory(name)`
  4579. * Returns a `boolean` indicating whether the removal succeeded.
  4580. * `minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)`:
  4581. returns leftover ItemStack or nil to indicate no inventory change
  4582. * See `minetest.item_eat` and `minetest.register_on_item_eat`
  4583. Formspec
  4584. --------
  4585. * `minetest.show_formspec(playername, formname, formspec)`
  4586. * `playername`: name of player to show formspec
  4587. * `formname`: name passed to `on_player_receive_fields` callbacks.
  4588. It should follow the `"modname:<whatever>"` naming convention
  4589. * `formspec`: formspec to display
  4590. * `minetest.close_formspec(playername, formname)`
  4591. * `playername`: name of player to close formspec
  4592. * `formname`: has to exactly match the one given in `show_formspec`, or the
  4593. formspec will not close.
  4594. * calling `show_formspec(playername, formname, "")` is equal to this
  4595. expression.
  4596. * to close a formspec regardless of the formname, call
  4597. `minetest.close_formspec(playername, "")`.
  4598. **USE THIS ONLY WHEN ABSOLUTELY NECESSARY!**
  4599. * `minetest.formspec_escape(string)`: returns a string
  4600. * escapes the characters "[", "]", "\", "," and ";", which can not be used
  4601. in formspecs.
  4602. * `minetest.explode_table_event(string)`: returns a table
  4603. * returns e.g. `{type="CHG", row=1, column=2}`
  4604. * `type` is one of:
  4605. * `"INV"`: no row selected
  4606. * `"CHG"`: selected
  4607. * `"DCL"`: double-click
  4608. * `minetest.explode_textlist_event(string)`: returns a table
  4609. * returns e.g. `{type="CHG", index=1}`
  4610. * `type` is one of:
  4611. * `"INV"`: no row selected
  4612. * `"CHG"`: selected
  4613. * `"DCL"`: double-click
  4614. * `minetest.explode_scrollbar_event(string)`: returns a table
  4615. * returns e.g. `{type="CHG", value=500}`
  4616. * `type` is one of:
  4617. * `"INV"`: something failed
  4618. * `"CHG"`: has been changed
  4619. * `"VAL"`: not changed
  4620. Item handling
  4621. -------------
  4622. * `minetest.inventorycube(img1, img2, img3)`
  4623. * Returns a string for making an image of a cube (useful as an item image)
  4624. * `minetest.get_pointed_thing_position(pointed_thing, above)`
  4625. * Returns the position of a `pointed_thing` or `nil` if the `pointed_thing`
  4626. does not refer to a node or entity.
  4627. * If the optional `above` parameter is true and the `pointed_thing` refers
  4628. to a node, then it will return the `above` position of the `pointed_thing`.
  4629. * `minetest.dir_to_facedir(dir, is6d)`
  4630. * Convert a vector to a facedir value, used in `param2` for
  4631. `paramtype2="facedir"`.
  4632. * passing something non-`nil`/`false` for the optional second parameter
  4633. causes it to take the y component into account.
  4634. * `minetest.facedir_to_dir(facedir)`
  4635. * Convert a facedir back into a vector aimed directly out the "back" of a
  4636. node.
  4637. * `minetest.dir_to_wallmounted(dir)`
  4638. * Convert a vector to a wallmounted value, used for
  4639. `paramtype2="wallmounted"`.
  4640. * `minetest.wallmounted_to_dir(wallmounted)`
  4641. * Convert a wallmounted value back into a vector aimed directly out the
  4642. "back" of a node.
  4643. * `minetest.dir_to_yaw(dir)`
  4644. * Convert a vector into a yaw (angle)
  4645. * `minetest.yaw_to_dir(yaw)`
  4646. * Convert yaw (angle) to a vector
  4647. * `minetest.is_colored_paramtype(ptype)`
  4648. * Returns a boolean. Returns `true` if the given `paramtype2` contains
  4649. color information (`color`, `colorwallmounted` or `colorfacedir`).
  4650. * `minetest.strip_param2_color(param2, paramtype2)`
  4651. * Removes everything but the color information from the
  4652. given `param2` value.
  4653. * Returns `nil` if the given `paramtype2` does not contain color
  4654. information.
  4655. * `minetest.get_node_drops(node, toolname)`
  4656. * Returns list of itemstrings that are dropped by `node` when dug
  4657. with the item `toolname` (not limited to tools).
  4658. * `node`: node as table or node name
  4659. * `toolname`: name of the item used to dig (can be `nil`)
  4660. * `minetest.get_craft_result(input)`: returns `output, decremented_input`
  4661. * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
  4662. * `input.width` = for example `3`
  4663. * `input.items` = for example
  4664. `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
  4665. * `output.item` = `ItemStack`, if unsuccessful: empty `ItemStack`
  4666. * `output.time` = a number, if unsuccessful: `0`
  4667. * `output.replacements` = List of replacement `ItemStack`s that couldn't be
  4668. placed in `decremented_input.items`. Replacements can be placed in
  4669. `decremented_input` if the stack of the replaced item has a count of 1.
  4670. * `decremented_input` = like `input`
  4671. * `minetest.get_craft_recipe(output)`: returns input
  4672. * returns last registered recipe for output item (node)
  4673. * `output` is a node or item type such as `"default:torch"`
  4674. * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
  4675. * `input.width` = for example `3`
  4676. * `input.items` = for example
  4677. `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
  4678. * `input.items` = `nil` if no recipe found
  4679. * `minetest.get_all_craft_recipes(query item)`: returns a table or `nil`
  4680. * returns indexed table with all registered recipes for query item (node)
  4681. or `nil` if no recipe was found.
  4682. * recipe entry table:
  4683. * `method`: 'normal' or 'cooking' or 'fuel'
  4684. * `width`: 0-3, 0 means shapeless recipe
  4685. * `items`: indexed [1-9] table with recipe items
  4686. * `output`: string with item name and quantity
  4687. * Example result for `"default:gold_ingot"` with two recipes:
  4688. {
  4689. {
  4690. method = "cooking", width = 3,
  4691. output = "default:gold_ingot", items = {"default:gold_lump"}
  4692. },
  4693. {
  4694. method = "normal", width = 1,
  4695. output = "default:gold_ingot 9", items = {"default:goldblock"}
  4696. }
  4697. }
  4698. * `minetest.handle_node_drops(pos, drops, digger)`
  4699. * `drops`: list of itemstrings
  4700. * Handles drops from nodes after digging: Default action is to put them
  4701. into digger's inventory.
  4702. * Can be overridden to get different functionality (e.g. dropping items on
  4703. ground)
  4704. * `minetest.itemstring_with_palette(item, palette_index)`: returns an item
  4705. string.
  4706. * Creates an item string which contains palette index information
  4707. for hardware colorization. You can use the returned string
  4708. as an output in a craft recipe.
  4709. * `item`: the item stack which becomes colored. Can be in string,
  4710. table and native form.
  4711. * `palette_index`: this index is added to the item stack
  4712. * `minetest.itemstring_with_color(item, colorstring)`: returns an item string
  4713. * Creates an item string which contains static color information
  4714. for hardware colorization. Use this method if you wish to colorize
  4715. an item that does not own a palette. You can use the returned string
  4716. as an output in a craft recipe.
  4717. * `item`: the item stack which becomes colored. Can be in string,
  4718. table and native form.
  4719. * `colorstring`: the new color of the item stack
  4720. Rollback
  4721. --------
  4722. * `minetest.rollback_get_node_actions(pos, range, seconds, limit)`:
  4723. returns `{{actor, pos, time, oldnode, newnode}, ...}`
  4724. * Find who has done something to a node, or near a node
  4725. * `actor`: `"player:<name>"`, also `"liquid"`.
  4726. * `minetest.rollback_revert_actions_by(actor, seconds)`: returns
  4727. `boolean, log_messages`.
  4728. * Revert latest actions of someone
  4729. * `actor`: `"player:<name>"`, also `"liquid"`.
  4730. Defaults for the `on_place` and `on_drop` item definition functions
  4731. -------------------------------------------------------------------
  4732. * `minetest.item_place_node(itemstack, placer, pointed_thing[, param2, prevent_after_place])`
  4733. * Place item as a node
  4734. * `param2` overrides `facedir` and wallmounted `param2`
  4735. * `prevent_after_place`: if set to `true`, `after_place_node` is not called
  4736. for the newly placed node to prevent a callback and placement loop
  4737. * returns `itemstack, position`
  4738. * `position`: the location the node was placed to. `nil` if nothing was placed.
  4739. * `minetest.item_place_object(itemstack, placer, pointed_thing)`
  4740. * Place item as-is
  4741. * returns the leftover itemstack
  4742. * **Note**: This function is deprecated and will never be called.
  4743. * `minetest.item_place(itemstack, placer, pointed_thing[, param2])`
  4744. * Wrapper that calls `minetest.item_place_node` if appropriate
  4745. * Calls `on_rightclick` of `pointed_thing.under` if defined instead
  4746. * **Note**: is not called when wielded item overrides `on_place`
  4747. * `param2` overrides facedir and wallmounted `param2`
  4748. * returns `itemstack, position`
  4749. * `position`: the location the node was placed to. `nil` if nothing was placed.
  4750. * `minetest.item_drop(itemstack, dropper, pos)`
  4751. * Drop the item
  4752. * returns the leftover itemstack
  4753. * `minetest.item_eat(hp_change[, replace_with_item])`
  4754. * Returns `function(itemstack, user, pointed_thing)` as a
  4755. function wrapper for `minetest.do_item_eat`.
  4756. * `replace_with_item` is the itemstring which is added to the inventory.
  4757. If the player is eating a stack, then replace_with_item goes to a
  4758. different spot.
  4759. Defaults for the `on_punch` and `on_dig` node definition callbacks
  4760. ------------------------------------------------------------------
  4761. * `minetest.node_punch(pos, node, puncher, pointed_thing)`
  4762. * Calls functions registered by `minetest.register_on_punchnode()`
  4763. * `minetest.node_dig(pos, node, digger)`
  4764. * Checks if node can be dug, puts item into inventory, removes node
  4765. * Calls functions registered by `minetest.registered_on_dignodes()`
  4766. Sounds
  4767. ------
  4768. * `minetest.sound_play(spec, parameters, [ephemeral])`: returns a handle
  4769. * `spec` is a `SimpleSoundSpec`
  4770. * `parameters` is a sound parameter table
  4771. * `ephemeral` is a boolean (default: false)
  4772. Ephemeral sounds will not return a handle and can't be stopped or faded.
  4773. It is recommend to use this for short sounds that happen in response to
  4774. player actions (e.g. door closing).
  4775. * `minetest.sound_stop(handle)`
  4776. * `handle` is a handle returned by `minetest.sound_play`
  4777. * `minetest.sound_fade(handle, step, gain)`
  4778. * `handle` is a handle returned by `minetest.sound_play`
  4779. * `step` determines how fast a sound will fade.
  4780. The gain will change by this much per second,
  4781. until it reaches the target gain.
  4782. Note: Older versions used a signed step. This is deprecated, but old
  4783. code will still work. (the client uses abs(step) to correct it)
  4784. * `gain` the target gain for the fade.
  4785. Fading to zero will delete the sound.
  4786. Timing
  4787. ------
  4788. * `minetest.after(time, func, ...)` : returns job table to use as below.
  4789. * Call the function `func` after `time` seconds, may be fractional
  4790. * Optional: Variable number of arguments that are passed to `func`
  4791. * `job:cancel()`
  4792. * Cancels the job function from being called
  4793. Async environment
  4794. -----------------
  4795. The engine allows you to submit jobs to be ran in an isolated environment
  4796. concurrently with normal server operation.
  4797. A job consists of a function to be ran in the async environment, any amount of
  4798. arguments (will be serialized) and a callback that will be called with the return
  4799. value of the job function once it is finished.
  4800. The async environment does *not* have access to the map, entities, players or any
  4801. globals defined in the 'usual' environment. Consequently, functions like
  4802. `minetest.get_node()` or `minetest.get_player_by_name()` simply do not exist in it.
  4803. Arguments and return values passed through this can contain certain userdata
  4804. objects that will be seamlessly copied (not shared) to the async environment.
  4805. This allows you easy interoperability for delegating work to jobs.
  4806. * `minetest.handle_async(func, callback, ...)`:
  4807. * Queue the function `func` to be ran in an async environment.
  4808. Note that there are multiple persistent workers and any of them may
  4809. end up running a given job. The engine will scale the amount of
  4810. worker threads automatically.
  4811. * When `func` returns the callback is called (in the normal environment)
  4812. with all of the return values as arguments.
  4813. * Optional: Variable number of arguments that are passed to `func`
  4814. * `minetest.register_async_dofile(path)`:
  4815. * Register a path to a Lua file to be imported when an async environment
  4816. is initialized. You can use this to preload code which you can then call
  4817. later using `minetest.handle_async()`.
  4818. ### List of APIs available in an async environment
  4819. Classes:
  4820. * `ItemStack`
  4821. * `PerlinNoise`
  4822. * `PerlinNoiseMap`
  4823. * `PseudoRandom`
  4824. * `PcgRandom`
  4825. * `SecureRandom`
  4826. * `VoxelArea`
  4827. * `VoxelManip`
  4828. * only if transferred into environment; can't read/write to map
  4829. * `Settings`
  4830. Class instances that can be transferred between environments:
  4831. * `ItemStack`
  4832. * `PerlinNoise`
  4833. * `PerlinNoiseMap`
  4834. * `VoxelManip`
  4835. Functions:
  4836. * Standalone helpers such as logging, filesystem, encoding,
  4837. hashing or compression APIs
  4838. * `minetest.request_insecure_environment` (same restrictions apply)
  4839. Variables:
  4840. * `minetest.settings`
  4841. * `minetest.registered_items`, `registered_nodes`, `registered_tools`,
  4842. `registered_craftitems` and `registered_aliases`
  4843. * with all functions and userdata values replaced by `true`, calling any
  4844. callbacks here is obviously not possible
  4845. Server
  4846. ------
  4847. * `minetest.request_shutdown([message],[reconnect],[delay])`: request for
  4848. server shutdown. Will display `message` to clients.
  4849. * `reconnect` == true displays a reconnect button
  4850. * `delay` adds an optional delay (in seconds) before shutdown.
  4851. Negative delay cancels the current active shutdown.
  4852. Zero delay triggers an immediate shutdown.
  4853. * `minetest.cancel_shutdown_requests()`: cancel current delayed shutdown
  4854. * `minetest.get_server_status(name, joined)`
  4855. * Returns the server status string when a player joins or when the command
  4856. `/status` is called. Returns `nil` or an empty string when the message is
  4857. disabled.
  4858. * `joined`: Boolean value, indicates whether the function was called when
  4859. a player joined.
  4860. * This function may be overwritten by mods to customize the status message.
  4861. * `minetest.get_server_uptime()`: returns the server uptime in seconds
  4862. * `minetest.get_server_max_lag()`: returns the current maximum lag
  4863. of the server in seconds or nil if server is not fully loaded yet
  4864. * `minetest.remove_player(name)`: remove player from database (if they are not
  4865. connected).
  4866. * As auth data is not removed, minetest.player_exists will continue to
  4867. return true. Call the below method as well if you want to remove auth
  4868. data too.
  4869. * Returns a code (0: successful, 1: no such player, 2: player is connected)
  4870. * `minetest.remove_player_auth(name)`: remove player authentication data
  4871. * Returns boolean indicating success (false if player nonexistant)
  4872. * `minetest.dynamic_add_media(options, callback)`
  4873. * `options`: table containing the following parameters
  4874. * `filepath`: path to a media file on the filesystem
  4875. * `to_player`: name of the player the media should be sent to instead of
  4876. all players (optional)
  4877. * `ephemeral`: boolean that marks the media as ephemeral,
  4878. it will not be cached on the client (optional, default false)
  4879. * `callback`: function with arguments `name`, which is a player name
  4880. * Pushes the specified media file to client(s). (details below)
  4881. The file must be a supported image, sound or model format.
  4882. Dynamically added media is not persisted between server restarts.
  4883. * Returns false on error, true if the request was accepted
  4884. * The given callback will be called for every player as soon as the
  4885. media is available on the client.
  4886. * Details/Notes:
  4887. * If `ephemeral`=false and `to_player` is unset the file is added to the media
  4888. sent to clients on startup, this means the media will appear even on
  4889. old clients if they rejoin the server.
  4890. * If `ephemeral`=false the file must not be modified, deleted, moved or
  4891. renamed after calling this function.
  4892. * Regardless of any use of `ephemeral`, adding media files with the same
  4893. name twice is not possible/guaranteed to work. An exception to this is the
  4894. use of `to_player` to send the same, already existent file to multiple
  4895. chosen players.
  4896. * Clients will attempt to fetch files added this way via remote media,
  4897. this can make transfer of bigger files painless (if set up). Nevertheless
  4898. it is advised not to use dynamic media for big media files.
  4899. Bans
  4900. ----
  4901. * `minetest.get_ban_list()`: returns a list of all bans formatted as string
  4902. * `minetest.get_ban_description(ip_or_name)`: returns list of bans matching
  4903. IP address or name formatted as string
  4904. * `minetest.ban_player(name)`: ban the IP of a currently connected player
  4905. * Returns boolean indicating success
  4906. * `minetest.unban_player_or_ip(ip_or_name)`: remove ban record matching
  4907. IP address or name
  4908. * `minetest.kick_player(name, [reason])`: disconnect a player with an optional
  4909. reason.
  4910. * Returns boolean indicating success (false if player nonexistant)
  4911. * `minetest.disconnect_player(name, [reason])`: disconnect a player with an
  4912. optional reason, this will not prefix with 'Kicked: ' like kick_player.
  4913. If no reason is given, it will default to 'Disconnected.'
  4914. * Returns boolean indicating success (false if player nonexistant)
  4915. Particles
  4916. ---------
  4917. * `minetest.add_particle(particle definition)`
  4918. * Deprecated: `minetest.add_particle(pos, velocity, acceleration,
  4919. expirationtime, size, collisiondetection, texture, playername)`
  4920. * `minetest.add_particlespawner(particlespawner definition)`
  4921. * Add a `ParticleSpawner`, an object that spawns an amount of particles
  4922. over `time` seconds.
  4923. * Returns an `id`, and -1 if adding didn't succeed
  4924. * Deprecated: `minetest.add_particlespawner(amount, time,
  4925. minpos, maxpos,
  4926. minvel, maxvel,
  4927. minacc, maxacc,
  4928. minexptime, maxexptime,
  4929. minsize, maxsize,
  4930. collisiondetection, texture, playername)`
  4931. * `minetest.delete_particlespawner(id, player)`
  4932. * Delete `ParticleSpawner` with `id` (return value from
  4933. `minetest.add_particlespawner`).
  4934. * If playername is specified, only deletes on the player's client,
  4935. otherwise on all clients.
  4936. Schematics
  4937. ----------
  4938. * `minetest.create_schematic(p1, p2, probability_list, filename, slice_prob_list)`
  4939. * Create a schematic from the volume of map specified by the box formed by
  4940. p1 and p2.
  4941. * Apply the specified probability and per-node force-place to the specified
  4942. nodes according to the `probability_list`.
  4943. * `probability_list` is an array of tables containing two fields, `pos`
  4944. and `prob`.
  4945. * `pos` is the 3D vector specifying the absolute coordinates of the
  4946. node being modified,
  4947. * `prob` is an integer value from `0` to `255` that encodes
  4948. probability and per-node force-place. Probability has levels
  4949. 0-127, then 128 may be added to encode per-node force-place.
  4950. For probability stated as 0-255, divide by 2 and round down to
  4951. get values 0-127, then add 128 to apply per-node force-place.
  4952. * If there are two or more entries with the same pos value, the
  4953. last entry is used.
  4954. * If `pos` is not inside the box formed by `p1` and `p2`, it is
  4955. ignored.
  4956. * If `probability_list` equals `nil`, no probabilities are applied.
  4957. * Apply the specified probability to the specified horizontal slices
  4958. according to the `slice_prob_list`.
  4959. * `slice_prob_list` is an array of tables containing two fields, `ypos`
  4960. and `prob`.
  4961. * `ypos` indicates the y position of the slice with a probability
  4962. applied, the lowest slice being `ypos = 0`.
  4963. * If slice probability list equals `nil`, no slice probabilities
  4964. are applied.
  4965. * Saves schematic in the Minetest Schematic format to filename.
  4966. * `minetest.place_schematic(pos, schematic, rotation, replacements, force_placement, flags)`
  4967. * Place the schematic specified by schematic (see [Schematic specifier]) at
  4968. `pos`.
  4969. * `rotation` can equal `"0"`, `"90"`, `"180"`, `"270"`, or `"random"`.
  4970. * If the `rotation` parameter is omitted, the schematic is not rotated.
  4971. * `replacements` = `{["old_name"] = "convert_to", ...}`
  4972. * `force_placement` is a boolean indicating whether nodes other than `air`
  4973. and `ignore` are replaced by the schematic.
  4974. * Returns nil if the schematic could not be loaded.
  4975. * **Warning**: Once you have loaded a schematic from a file, it will be
  4976. cached. Future calls will always use the cached version and the
  4977. replacement list defined for it, regardless of whether the file or the
  4978. replacement list parameter have changed. The only way to load the file
  4979. anew is to restart the server.
  4980. * `flags` is a flag field with the available flags:
  4981. * place_center_x
  4982. * place_center_y
  4983. * place_center_z
  4984. * `minetest.place_schematic_on_vmanip(vmanip, pos, schematic, rotation, replacement, force_placement, flags)`:
  4985. * This function is analogous to minetest.place_schematic, but places a
  4986. schematic onto the specified VoxelManip object `vmanip` instead of the
  4987. map.
  4988. * Returns false if any part of the schematic was cut-off due to the
  4989. VoxelManip not containing the full area required, and true if the whole
  4990. schematic was able to fit.
  4991. * Returns nil if the schematic could not be loaded.
  4992. * After execution, any external copies of the VoxelManip contents are
  4993. invalidated.
  4994. * `flags` is a flag field with the available flags:
  4995. * place_center_x
  4996. * place_center_y
  4997. * place_center_z
  4998. * `minetest.serialize_schematic(schematic, format, options)`
  4999. * Return the serialized schematic specified by schematic
  5000. (see [Schematic specifier])
  5001. * in the `format` of either "mts" or "lua".
  5002. * "mts" - a string containing the binary MTS data used in the MTS file
  5003. format.
  5004. * "lua" - a string containing Lua code representing the schematic in table
  5005. format.
  5006. * `options` is a table containing the following optional parameters:
  5007. * If `lua_use_comments` is true and `format` is "lua", the Lua code
  5008. generated will have (X, Z) position comments for every X row
  5009. generated in the schematic data for easier reading.
  5010. * If `lua_num_indent_spaces` is a nonzero number and `format` is "lua",
  5011. the Lua code generated will use that number of spaces as indentation
  5012. instead of a tab character.
  5013. * `minetest.read_schematic(schematic, options)`
  5014. * Returns a Lua table representing the schematic (see: [Schematic specifier])
  5015. * `schematic` is the schematic to read (see: [Schematic specifier])
  5016. * `options` is a table containing the following optional parameters:
  5017. * `write_yslice_prob`: string value:
  5018. * `none`: no `write_yslice_prob` table is inserted,
  5019. * `low`: only probabilities that are not 254 or 255 are written in
  5020. the `write_ylisce_prob` table,
  5021. * `all`: write all probabilities to the `write_yslice_prob` table.
  5022. * The default for this option is `all`.
  5023. * Any invalid value will be interpreted as `all`.
  5024. HTTP Requests
  5025. -------------
  5026. * `minetest.request_http_api()`:
  5027. * returns `HTTPApiTable` containing http functions if the calling mod has
  5028. been granted access by being listed in the `secure.http_mods` or
  5029. `secure.trusted_mods` setting, otherwise returns `nil`.
  5030. * The returned table contains the functions `fetch`, `fetch_async` and
  5031. `fetch_async_get` described below.
  5032. * Only works at init time and must be called from the mod's main scope
  5033. (not from a function).
  5034. * Function only exists if minetest server was built with cURL support.
  5035. * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED TABLE, STORE IT IN
  5036. A LOCAL VARIABLE!**
  5037. * `HTTPApiTable.fetch(HTTPRequest req, callback)`
  5038. * Performs given request asynchronously and calls callback upon completion
  5039. * callback: `function(HTTPRequestResult res)`
  5040. * Use this HTTP function if you are unsure, the others are for advanced use
  5041. * `HTTPApiTable.fetch_async(HTTPRequest req)`: returns handle
  5042. * Performs given request asynchronously and returns handle for
  5043. `HTTPApiTable.fetch_async_get`
  5044. * `HTTPApiTable.fetch_async_get(handle)`: returns HTTPRequestResult
  5045. * Return response data for given asynchronous HTTP request
  5046. Storage API
  5047. -----------
  5048. * `minetest.get_mod_storage()`:
  5049. * returns reference to mod private `StorageRef`
  5050. * must be called during mod load time
  5051. Misc.
  5052. -----
  5053. * `minetest.get_connected_players()`: returns list of `ObjectRefs`
  5054. * `minetest.is_player(obj)`: boolean, whether `obj` is a player
  5055. * `minetest.player_exists(name)`: boolean, whether player exists
  5056. (regardless of online status)
  5057. * `minetest.hud_replace_builtin(name, hud_definition)`
  5058. * Replaces definition of a builtin hud element
  5059. * `name`: `"breath"` or `"health"`
  5060. * `hud_definition`: definition to replace builtin definition
  5061. * `minetest.send_join_message(player_name)`
  5062. * This function can be overridden by mods to change the join message.
  5063. * `minetest.send_leave_message(player_name, timed_out)`
  5064. * This function can be overridden by mods to change the leave message.
  5065. * `minetest.hash_node_position(pos)`: returns an 48-bit integer
  5066. * `pos`: table {x=number, y=number, z=number},
  5067. * Gives a unique hash number for a node position (16+16+16=48bit)
  5068. * `minetest.get_position_from_hash(hash)`: returns a position
  5069. * Inverse transform of `minetest.hash_node_position`
  5070. * `minetest.get_item_group(name, group)`: returns a rating
  5071. * Get rating of a group of an item. (`0` means: not in group)
  5072. * `minetest.get_node_group(name, group)`: returns a rating
  5073. * Deprecated: An alias for the former.
  5074. * `minetest.raillike_group(name)`: returns a rating
  5075. * Returns rating of the connect_to_raillike group corresponding to name
  5076. * If name is not yet the name of a connect_to_raillike group, a new group
  5077. id is created, with that name.
  5078. * `minetest.get_content_id(name)`: returns an integer
  5079. * Gets the internal content ID of `name`
  5080. * `minetest.get_name_from_content_id(content_id)`: returns a string
  5081. * Gets the name of the content with that content ID
  5082. * `minetest.parse_json(string[, nullvalue])`: returns something
  5083. * Convert a string containing JSON data into the Lua equivalent
  5084. * `nullvalue`: returned in place of the JSON null; defaults to `nil`
  5085. * On success returns a table, a string, a number, a boolean or `nullvalue`
  5086. * On failure outputs an error message and returns `nil`
  5087. * Example: `parse_json("[10, {\"a\":false}]")`, returns `{10, {a = false}}`
  5088. * `minetest.write_json(data[, styled])`: returns a string or `nil` and an error
  5089. message.
  5090. * Convert a Lua table into a JSON string
  5091. * styled: Outputs in a human-readable format if this is set, defaults to
  5092. false.
  5093. * Unserializable things like functions and userdata will cause an error.
  5094. * **Warning**: JSON is more strict than the Lua table format.
  5095. 1. You can only use strings and positive integers of at least one as
  5096. keys.
  5097. 2. You can not mix string and integer keys.
  5098. This is due to the fact that JSON has two distinct array and object
  5099. values.
  5100. * Example: `write_json({10, {a = false}})`,
  5101. returns `'[10, {"a": false}]'`
  5102. * `minetest.serialize(table)`: returns a string
  5103. * Convert a table containing tables, strings, numbers, booleans and `nil`s
  5104. into string form readable by `minetest.deserialize`
  5105. * Example: `serialize({foo="bar"})`, returns `'return { ["foo"] = "bar" }'`
  5106. * `minetest.deserialize(string[, safe])`: returns a table
  5107. * Convert a string returned by `minetest.serialize` into a table
  5108. * `string` is loaded in an empty sandbox environment.
  5109. * Will load functions if safe is false or omitted. Although these functions
  5110. cannot directly access the global environment, they could bypass this
  5111. restriction with maliciously crafted Lua bytecode if mod security is
  5112. disabled.
  5113. * This function should not be used on untrusted data, regardless of the
  5114. value of `safe`. It is fine to serialize then deserialize user-provided
  5115. data, but directly providing user input to deserialize is always unsafe.
  5116. * Example: `deserialize('return { ["foo"] = "bar" }')`,
  5117. returns `{foo="bar"}`
  5118. * Example: `deserialize('print("foo")')`, returns `nil`
  5119. (function call fails), returns
  5120. `error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value)`
  5121. * `minetest.compress(data, method, ...)`: returns `compressed_data`
  5122. * Compress a string of data.
  5123. * `method` is a string identifying the compression method to be used.
  5124. * Supported compression methods:
  5125. * Deflate (zlib): `"deflate"`
  5126. * `...` indicates method-specific arguments. Currently defined arguments
  5127. are:
  5128. * Deflate: `level` - Compression level, `0`-`9` or `nil`.
  5129. * `minetest.decompress(compressed_data, method, ...)`: returns data
  5130. * Decompress a string of data (using ZLib).
  5131. * See documentation on `minetest.compress()` for supported compression
  5132. methods.
  5133. * `...` indicates method-specific arguments. Currently, no methods use this
  5134. * `minetest.rgba(red, green, blue[, alpha])`: returns a string
  5135. * Each argument is a 8 Bit unsigned integer
  5136. * Returns the ColorString from rgb or rgba values
  5137. * Example: `minetest.rgba(10, 20, 30, 40)`, returns `"#0A141E28"`
  5138. * `minetest.encode_base64(string)`: returns string encoded in base64
  5139. * Encodes a string in base64.
  5140. * `minetest.decode_base64(string)`: returns string or nil on failure
  5141. * Padding characters are only supported starting at version 5.4.0, where
  5142. 5.5.0 and newer perform proper checks.
  5143. * Decodes a string encoded in base64.
  5144. * `minetest.is_protected(pos, name)`: returns boolean
  5145. * Returning `true` restricts the player `name` from modifying (i.e. digging,
  5146. placing) the node at position `pos`.
  5147. * `name` will be `""` for non-players or unknown players.
  5148. * This function should be overridden by protection mods. It is highly
  5149. recommended to grant access to players with the `protection_bypass` privilege.
  5150. * Cache and call the old version of this function if the position is
  5151. not protected by the mod. This will allow using multiple protection mods.
  5152. * Example:
  5153. local old_is_protected = minetest.is_protected
  5154. function minetest.is_protected(pos, name)
  5155. if mymod:position_protected_from(pos, name) then
  5156. return true
  5157. end
  5158. return old_is_protected(pos, name)
  5159. end
  5160. * `minetest.record_protection_violation(pos, name)`
  5161. * This function calls functions registered with
  5162. `minetest.register_on_protection_violation`.
  5163. * `minetest.is_creative_enabled(name)`: returns boolean
  5164. * Returning `true` means that Creative Mode is enabled for player `name`.
  5165. * `name` will be `""` for non-players or if the player is unknown.
  5166. * This function should be overridden by Creative Mode-related mods to
  5167. implement a per-player Creative Mode.
  5168. * By default, this function returns `true` if the setting
  5169. `creative_mode` is `true` and `false` otherwise.
  5170. * `minetest.is_area_protected(pos1, pos2, player_name, interval)`
  5171. * Returns the position of the first node that `player_name` may not modify
  5172. in the specified cuboid between `pos1` and `pos2`.
  5173. * Returns `false` if no protections were found.
  5174. * Applies `is_protected()` to a 3D lattice of points in the defined volume.
  5175. The points are spaced evenly throughout the volume and have a spacing
  5176. similar to, but no larger than, `interval`.
  5177. * All corners and edges of the defined volume are checked.
  5178. * `interval` defaults to 4.
  5179. * `interval` should be carefully chosen and maximised to avoid an excessive
  5180. number of points being checked.
  5181. * Like `minetest.is_protected`, this function may be extended or
  5182. overwritten by mods to provide a faster implementation to check the
  5183. cuboid for intersections.
  5184. * `minetest.rotate_and_place(itemstack, placer, pointed_thing[, infinitestacks,
  5185. orient_flags, prevent_after_place])`
  5186. * Attempt to predict the desired orientation of the facedir-capable node
  5187. defined by `itemstack`, and place it accordingly (on-wall, on the floor,
  5188. or hanging from the ceiling).
  5189. * `infinitestacks`: if `true`, the itemstack is not changed. Otherwise the
  5190. stacks are handled normally.
  5191. * `orient_flags`: Optional table containing extra tweaks to the placement code:
  5192. * `invert_wall`: if `true`, place wall-orientation on the ground and
  5193. ground-orientation on the wall.
  5194. * `force_wall` : if `true`, always place the node in wall orientation.
  5195. * `force_ceiling`: if `true`, always place on the ceiling.
  5196. * `force_floor`: if `true`, always place the node on the floor.
  5197. * `force_facedir`: if `true`, forcefully reset the facedir to north
  5198. when placing on the floor or ceiling.
  5199. * The first four options are mutually-exclusive; the last in the list
  5200. takes precedence over the first.
  5201. * `prevent_after_place` is directly passed to `minetest.item_place_node`
  5202. * Returns the new itemstack after placement
  5203. * `minetest.rotate_node(itemstack, placer, pointed_thing)`
  5204. * calls `rotate_and_place()` with `infinitestacks` set according to the state
  5205. of the creative mode setting, checks for "sneak" to set the `invert_wall`
  5206. parameter and `prevent_after_place` set to `true`.
  5207. * `minetest.calculate_knockback(player, hitter, time_from_last_punch,
  5208. tool_capabilities, dir, distance, damage)`
  5209. * Returns the amount of knockback applied on the punched player.
  5210. * Arguments are equivalent to `register_on_punchplayer`, except the following:
  5211. * `distance`: distance between puncher and punched player
  5212. * This function can be overriden by mods that wish to modify this behaviour.
  5213. * You may want to cache and call the old function to allow multiple mods to
  5214. change knockback behaviour.
  5215. * `minetest.forceload_block(pos[, transient])`
  5216. * forceloads the position `pos`.
  5217. * returns `true` if area could be forceloaded
  5218. * If `transient` is `false` or absent, the forceload will be persistent
  5219. (saved between server runs). If `true`, the forceload will be transient
  5220. (not saved between server runs).
  5221. * `minetest.forceload_free_block(pos[, transient])`
  5222. * stops forceloading the position `pos`
  5223. * If `transient` is `false` or absent, frees a persistent forceload.
  5224. If `true`, frees a transient forceload.
  5225. * `minetest.compare_block_status(pos, condition)`
  5226. * Checks whether the mapblock at positition `pos` is in the wanted condition.
  5227. * `condition` may be one of the following values:
  5228. * `"unknown"`: not in memory
  5229. * `"emerging"`: in the queue for loading from disk or generating
  5230. * `"loaded"`: in memory but inactive (no ABMs are executed)
  5231. * `"active"`: in memory and active
  5232. * Other values are reserved for future functionality extensions
  5233. * Return value, the comparison status:
  5234. * `false`: Mapblock does not fulfil the wanted condition
  5235. * `true`: Mapblock meets the requirement
  5236. * `nil`: Unsupported `condition` value
  5237. * `minetest.request_insecure_environment()`: returns an environment containing
  5238. insecure functions if the calling mod has been listed as trusted in the
  5239. `secure.trusted_mods` setting or security is disabled, otherwise returns
  5240. `nil`.
  5241. * Only works at init time and must be called from the mod's main scope
  5242. (ie: the init.lua of the mod, not from another Lua file or within a function).
  5243. * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED ENVIRONMENT, STORE
  5244. IT IN A LOCAL VARIABLE!**
  5245. * `minetest.global_exists(name)`
  5246. * Checks if a global variable has been set, without triggering a warning.
  5247. Global objects
  5248. --------------
  5249. * `minetest.env`: `EnvRef` of the server environment and world.
  5250. * Any function in the minetest namespace can be called using the syntax
  5251. `minetest.env:somefunction(somearguments)`
  5252. instead of `minetest.somefunction(somearguments)`
  5253. * Deprecated, but support is not to be dropped soon
  5254. Global tables
  5255. -------------
  5256. ### Registered definition tables
  5257. * `minetest.registered_items`
  5258. * Map of registered items, indexed by name
  5259. * `minetest.registered_nodes`
  5260. * Map of registered node definitions, indexed by name
  5261. * `minetest.registered_craftitems`
  5262. * Map of registered craft item definitions, indexed by name
  5263. * `minetest.registered_tools`
  5264. * Map of registered tool definitions, indexed by name
  5265. * `minetest.registered_entities`
  5266. * Map of registered entity prototypes, indexed by name
  5267. * Values in this table may be modified directly.
  5268. Note: changes to initial properties will only affect entities spawned afterwards,
  5269. as they are only read when spawning.
  5270. * `minetest.object_refs`
  5271. * Map of object references, indexed by active object id
  5272. * `minetest.luaentities`
  5273. * Map of Lua entities, indexed by active object id
  5274. * `minetest.registered_abms`
  5275. * List of ABM definitions
  5276. * `minetest.registered_lbms`
  5277. * List of LBM definitions
  5278. * `minetest.registered_aliases`
  5279. * Map of registered aliases, indexed by name
  5280. * `minetest.registered_ores`
  5281. * Map of registered ore definitions, indexed by the `name` field.
  5282. * If `name` is nil, the key is the object handle returned by
  5283. `minetest.register_ore`.
  5284. * `minetest.registered_biomes`
  5285. * Map of registered biome definitions, indexed by the `name` field.
  5286. * If `name` is nil, the key is the object handle returned by
  5287. `minetest.register_biome`.
  5288. * `minetest.registered_decorations`
  5289. * Map of registered decoration definitions, indexed by the `name` field.
  5290. * If `name` is nil, the key is the object handle returned by
  5291. `minetest.register_decoration`.
  5292. * `minetest.registered_schematics`
  5293. * Map of registered schematic definitions, indexed by the `name` field.
  5294. * If `name` is nil, the key is the object handle returned by
  5295. `minetest.register_schematic`.
  5296. * `minetest.registered_chatcommands`
  5297. * Map of registered chat command definitions, indexed by name
  5298. * `minetest.registered_privileges`
  5299. * Map of registered privilege definitions, indexed by name
  5300. * Registered privileges can be modified directly in this table.
  5301. ### Registered callback tables
  5302. All callbacks registered with [Global callback registration functions] are added
  5303. to corresponding `minetest.registered_*` tables.
  5304. Class reference
  5305. ===============
  5306. Sorted alphabetically.
  5307. `AreaStore`
  5308. -----------
  5309. AreaStore is a data structure to calculate intersections of 3D cuboid volumes
  5310. and points. The `data` field (string) may be used to store and retrieve any
  5311. mod-relevant information to the specified area.
  5312. Despite its name, mods must take care of persisting AreaStore data. They may
  5313. use the provided load and write functions for this.
  5314. ### Methods
  5315. * `AreaStore(type_name)`
  5316. * Returns a new AreaStore instance
  5317. * `type_name`: optional, forces the internally used API.
  5318. * Possible values: `"LibSpatial"` (default).
  5319. * When other values are specified, or SpatialIndex is not available,
  5320. the custom Minetest functions are used.
  5321. * `get_area(id, include_corners, include_data)`
  5322. * Returns the area information about the specified ID.
  5323. * Returned values are either of these:
  5324. nil -- Area not found
  5325. true -- Without `include_corners` and `include_data`
  5326. {
  5327. min = pos, max = pos -- `include_corners == true`
  5328. data = string -- `include_data == true`
  5329. }
  5330. * `get_areas_for_pos(pos, include_corners, include_data)`
  5331. * Returns all areas as table, indexed by the area ID.
  5332. * Table values: see `get_area`.
  5333. * `get_areas_in_area(corner1, corner2, accept_overlap, include_corners, include_data)`
  5334. * Returns all areas that contain all nodes inside the area specified by`
  5335. `corner1 and `corner2` (inclusive).
  5336. * `accept_overlap`: if `true`, areas are returned that have nodes in
  5337. common (intersect) with the specified area.
  5338. * Returns the same values as `get_areas_for_pos`.
  5339. * `insert_area(corner1, corner2, data, [id])`: inserts an area into the store.
  5340. * Returns the new area's ID, or nil if the insertion failed.
  5341. * The (inclusive) positions `corner1` and `corner2` describe the area.
  5342. * `data` is a string stored with the area.
  5343. * `id` (optional): will be used as the internal area ID if it is an unique
  5344. number between 0 and 2^32-2.
  5345. * `reserve(count)`
  5346. * Requires SpatialIndex, no-op function otherwise.
  5347. * Reserves resources for `count` many contained areas to improve
  5348. efficiency when working with many area entries. Additional areas can still
  5349. be inserted afterwards at the usual complexity.
  5350. * `remove_area(id)`: removes the area with the given id from the store, returns
  5351. success.
  5352. * `set_cache_params(params)`: sets params for the included prefiltering cache.
  5353. Calling invalidates the cache, so that its elements have to be newly
  5354. generated.
  5355. * `params` is a table with the following fields:
  5356. enabled = boolean, -- Whether to enable, default true
  5357. block_radius = int, -- The radius (in nodes) of the areas the cache
  5358. -- generates prefiltered lists for, minimum 16,
  5359. -- default 64
  5360. limit = int, -- The cache size, minimum 20, default 1000
  5361. * `to_string()`: Experimental. Returns area store serialized as a (binary)
  5362. string.
  5363. * `to_file(filename)`: Experimental. Like `to_string()`, but writes the data to
  5364. a file.
  5365. * `from_string(str)`: Experimental. Deserializes string and loads it into the
  5366. AreaStore.
  5367. Returns success and, optionally, an error message.
  5368. * `from_file(filename)`: Experimental. Like `from_string()`, but reads the data
  5369. from a file.
  5370. `InvRef`
  5371. --------
  5372. An `InvRef` is a reference to an inventory.
  5373. ### Methods
  5374. * `is_empty(listname)`: return `true` if list is empty
  5375. * `get_size(listname)`: get size of a list
  5376. * `set_size(listname, size)`: set size of a list
  5377. * returns `false` on error (e.g. invalid `listname` or `size`)
  5378. * `get_width(listname)`: get width of a list
  5379. * `set_width(listname, width)`: set width of list; currently used for crafting
  5380. * `get_stack(listname, i)`: get a copy of stack index `i` in list
  5381. * `set_stack(listname, i, stack)`: copy `stack` to index `i` in list
  5382. * `get_list(listname)`: return full list (list of `ItemStack`s)
  5383. * `set_list(listname, list)`: set full list (size will not change)
  5384. * `get_lists()`: returns table that maps listnames to inventory lists
  5385. * `set_lists(lists)`: sets inventory lists (size will not change)
  5386. * `add_item(listname, stack)`: add item somewhere in list, returns leftover
  5387. `ItemStack`.
  5388. * `room_for_item(listname, stack):` returns `true` if the stack of items
  5389. can be fully added to the list
  5390. * `contains_item(listname, stack, [match_meta])`: returns `true` if
  5391. the stack of items can be fully taken from the list.
  5392. If `match_meta` is false, only the items' names are compared
  5393. (default: `false`).
  5394. * `remove_item(listname, stack)`: take as many items as specified from the
  5395. list, returns the items that were actually removed (as an `ItemStack`)
  5396. -- note that any item metadata is ignored, so attempting to remove a specific
  5397. unique item this way will likely remove the wrong one -- to do that use
  5398. `set_stack` with an empty `ItemStack`.
  5399. * `get_location()`: returns a location compatible to
  5400. `minetest.get_inventory(location)`.
  5401. * returns `{type="undefined"}` in case location is not known
  5402. ### Callbacks
  5403. Detached & nodemeta inventories provide the following callbacks for move actions:
  5404. #### Before
  5405. The `allow_*` callbacks return how many items can be moved.
  5406. * `allow_move`/`allow_metadata_inventory_move`: Moving items in the inventory
  5407. * `allow_take`/`allow_metadata_inventory_take`: Taking items from the inventory
  5408. * `allow_put`/`allow_metadata_inventory_put`: Putting items to the inventory
  5409. #### After
  5410. The `on_*` callbacks are called after the items have been placed in the inventories.
  5411. * `on_move`/`on_metadata_inventory_move`: Moving items in the inventory
  5412. * `on_take`/`on_metadata_inventory_take`: Taking items from the inventory
  5413. * `on_put`/`on_metadata_inventory_put`: Putting items to the inventory
  5414. #### Swapping
  5415. When a player tries to put an item to a place where another item is, the items are *swapped*.
  5416. This means that all callbacks will be called twice (once for each action).
  5417. `ItemStack`
  5418. -----------
  5419. An `ItemStack` is a stack of items.
  5420. It can be created via `ItemStack(x)`, where x is an `ItemStack`,
  5421. an itemstring, a table or `nil`.
  5422. ### Methods
  5423. * `is_empty()`: returns `true` if stack is empty.
  5424. * `get_name()`: returns item name (e.g. `"default:stone"`).
  5425. * `set_name(item_name)`: returns a boolean indicating whether the item was
  5426. cleared.
  5427. * `get_count()`: Returns number of items on the stack.
  5428. * `set_count(count)`: returns a boolean indicating whether the item was cleared
  5429. * `count`: number, unsigned 16 bit integer
  5430. * `get_wear()`: returns tool wear (`0`-`65535`), `0` for non-tools.
  5431. * `set_wear(wear)`: returns boolean indicating whether item was cleared
  5432. * `wear`: number, unsigned 16 bit integer
  5433. * `get_meta()`: returns ItemStackMetaRef. See section for more details
  5434. * `get_metadata()`: (DEPRECATED) Returns metadata (a string attached to an item
  5435. stack).
  5436. * `set_metadata(metadata)`: (DEPRECATED) Returns true.
  5437. * `get_description()`: returns the description shown in inventory list tooltips.
  5438. * The engine uses this when showing item descriptions in tooltips.
  5439. * Fields for finding the description, in order:
  5440. * `description` in item metadata (See [Item Metadata].)
  5441. * `description` in item definition
  5442. * item name
  5443. * `get_short_description()`: returns the short description or nil.
  5444. * Unlike the description, this does not include new lines.
  5445. * Fields for finding the short description, in order:
  5446. * `short_description` in item metadata (See [Item Metadata].)
  5447. * `short_description` in item definition
  5448. * first line of the description (From item meta or def, see `get_description()`.)
  5449. * Returns nil if none of the above are set
  5450. * `clear()`: removes all items from the stack, making it empty.
  5451. * `replace(item)`: replace the contents of this stack.
  5452. * `item` can also be an itemstring or table.
  5453. * `to_string()`: returns the stack in itemstring form.
  5454. * `to_table()`: returns the stack in Lua table form.
  5455. * `get_stack_max()`: returns the maximum size of the stack (depends on the
  5456. item).
  5457. * `get_free_space()`: returns `get_stack_max() - get_count()`.
  5458. * `is_known()`: returns `true` if the item name refers to a defined item type.
  5459. * `get_definition()`: returns the item definition table.
  5460. * `get_tool_capabilities()`: returns the digging properties of the item,
  5461. or those of the hand if none are defined for this item type
  5462. * `add_wear(amount)`
  5463. * Increases wear by `amount` if the item is a tool, otherwise does nothing
  5464. * Valid `amount` range is [0,65536]
  5465. * `amount`: number, integer
  5466. * `add_wear_by_uses(max_uses)`
  5467. * Increases wear in such a way that, if only this function is called,
  5468. the item breaks after `max_uses` times
  5469. * Valid `max_uses` range is [0,65536]
  5470. * Does nothing if item is not a tool or if `max_uses` is 0
  5471. * `add_item(item)`: returns leftover `ItemStack`
  5472. * Put some item or stack onto this stack
  5473. * `item_fits(item)`: returns `true` if item or stack can be fully added to
  5474. this one.
  5475. * `take_item(n)`: returns taken `ItemStack`
  5476. * Take (and remove) up to `n` items from this stack
  5477. * `n`: number, default: `1`
  5478. * `peek_item(n)`: returns taken `ItemStack`
  5479. * Copy (don't remove) up to `n` items from this stack
  5480. * `n`: number, default: `1`
  5481. `ItemStackMetaRef`
  5482. ------------------
  5483. ItemStack metadata: reference extra data and functionality stored in a stack.
  5484. Can be obtained via `item:get_meta()`.
  5485. ### Methods
  5486. * All methods in MetaDataRef
  5487. * `set_tool_capabilities([tool_capabilities])`
  5488. * Overrides the item's tool capabilities
  5489. * A nil value will clear the override data and restore the original
  5490. behavior.
  5491. `MetaDataRef`
  5492. -------------
  5493. Base class used by [`StorageRef`], [`NodeMetaRef`], [`ItemStackMetaRef`],
  5494. and [`PlayerMetaRef`].
  5495. ### Methods
  5496. * `contains(key)`: Returns true if key present, otherwise false.
  5497. * Returns `nil` when the MetaData is inexistent.
  5498. * `get(key)`: Returns `nil` if key not present, else the stored string.
  5499. * `set_string(key, value)`: Value of `""` will delete the key.
  5500. * `get_string(key)`: Returns `""` if key not present.
  5501. * `set_int(key, value)`
  5502. * `get_int(key)`: Returns `0` if key not present.
  5503. * `set_float(key, value)`
  5504. * `get_float(key)`: Returns `0` if key not present.
  5505. * `to_table()`: returns `nil` or a table with keys:
  5506. * `fields`: key-value storage
  5507. * `inventory`: `{list1 = {}, ...}}` (NodeMetaRef only)
  5508. * `from_table(nil or {})`
  5509. * Any non-table value will clear the metadata
  5510. * See [Node Metadata] for an example
  5511. * returns `true` on success
  5512. * `equals(other)`
  5513. * returns `true` if this metadata has the same key-value pairs as `other`
  5514. `ModChannel`
  5515. ------------
  5516. An interface to use mod channels on client and server
  5517. ### Methods
  5518. * `leave()`: leave the mod channel.
  5519. * Server leaves channel `channel_name`.
  5520. * No more incoming or outgoing messages can be sent to this channel from
  5521. server mods.
  5522. * This invalidate all future object usage.
  5523. * Ensure you set mod_channel to nil after that to free Lua resources.
  5524. * `is_writeable()`: returns true if channel is writeable and mod can send over
  5525. it.
  5526. * `send_all(message)`: Send `message` though the mod channel.
  5527. * If mod channel is not writeable or invalid, message will be dropped.
  5528. * Message size is limited to 65535 characters by protocol.
  5529. `NodeMetaRef`
  5530. -------------
  5531. Node metadata: reference extra data and functionality stored in a node.
  5532. Can be obtained via `minetest.get_meta(pos)`.
  5533. ### Methods
  5534. * All methods in MetaDataRef
  5535. * `get_inventory()`: returns `InvRef`
  5536. * `mark_as_private(name or {name1, name2, ...})`: Mark specific vars as private
  5537. This will prevent them from being sent to the client. Note that the "private"
  5538. status will only be remembered if an associated key-value pair exists,
  5539. meaning it's best to call this when initializing all other meta (e.g.
  5540. `on_construct`).
  5541. `NodeTimerRef`
  5542. --------------
  5543. Node Timers: a high resolution persistent per-node timer.
  5544. Can be gotten via `minetest.get_node_timer(pos)`.
  5545. ### Methods
  5546. * `set(timeout,elapsed)`
  5547. * set a timer's state
  5548. * `timeout` is in seconds, and supports fractional values (0.1 etc)
  5549. * `elapsed` is in seconds, and supports fractional values (0.1 etc)
  5550. * will trigger the node's `on_timer` function after `(timeout - elapsed)`
  5551. seconds.
  5552. * `start(timeout)`
  5553. * start a timer
  5554. * equivalent to `set(timeout,0)`
  5555. * `stop()`
  5556. * stops the timer
  5557. * `get_timeout()`: returns current timeout in seconds
  5558. * if `timeout` equals `0`, timer is inactive
  5559. * `get_elapsed()`: returns current elapsed time in seconds
  5560. * the node's `on_timer` function will be called after `(timeout - elapsed)`
  5561. seconds.
  5562. * `is_started()`: returns boolean state of timer
  5563. * returns `true` if timer is started, otherwise `false`
  5564. `ObjectRef`
  5565. -----------
  5566. Moving things in the game are generally these.
  5567. This is basically a reference to a C++ `ServerActiveObject`.
  5568. ### Advice on handling `ObjectRefs`
  5569. When you receive an `ObjectRef` as a callback argument or from another API
  5570. function, it is possible to store the reference somewhere and keep it around.
  5571. It will keep functioning until the object is unloaded or removed.
  5572. However, doing this is **NOT** recommended as there is (intentionally) no method
  5573. to test if a previously acquired `ObjectRef` is still valid.
  5574. Instead, `ObjectRefs` should be "let go" of as soon as control is returned from
  5575. Lua back to the engine.
  5576. Doing so is much less error-prone and you will never need to wonder if the
  5577. object you are working with still exists.
  5578. ### Attachments
  5579. It is possible to attach objects to other objects (`set_attach` method).
  5580. When an object is attached, it is positioned relative to the parent's position
  5581. and rotation. `get_pos` and `get_rotation` will always return the parent's
  5582. values and changes via their setter counterparts are ignored.
  5583. To change position or rotation call `set_attach` again with the new values.
  5584. **Note**: Just like model dimensions, the relative position in `set_attach`
  5585. must be multiplied by 10 compared to world positions.
  5586. It is also possible to attach to a bone of the parent object. In that case the
  5587. child will follow movement and rotation of that bone.
  5588. ### Methods
  5589. * `get_pos()`: returns `{x=num, y=num, z=num}`
  5590. * `set_pos(pos)`: `pos`=`{x=num, y=num, z=num}`
  5591. * `get_velocity()`: returns the velocity, a vector.
  5592. * `add_velocity(vel)`
  5593. * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
  5594. * In comparison to using get_velocity, adding the velocity and then using
  5595. set_velocity, add_velocity is supposed to avoid synchronization problems.
  5596. Additionally, players also do not support set_velocity.
  5597. * If a player:
  5598. * Does not apply during free_move.
  5599. * Note that since the player speed is normalized at each move step,
  5600. increasing e.g. Y velocity beyond what would usually be achieved
  5601. (see: physics overrides) will cause existing X/Z velocity to be reduced.
  5602. * Example: `add_velocity({x=0, y=6.5, z=0})` is equivalent to
  5603. pressing the jump key (assuming default settings)
  5604. * `move_to(pos, continuous=false)`
  5605. * Does an interpolated move for Lua entities for visually smooth transitions.
  5606. * If `continuous` is true, the Lua entity will not be moved to the current
  5607. position before starting the interpolated move.
  5608. * For players this does the same as `set_pos`,`continuous` is ignored.
  5609. * `punch(puncher, time_from_last_punch, tool_capabilities, direction)`
  5610. * `puncher` = another `ObjectRef`,
  5611. * `time_from_last_punch` = time since last punch action of the puncher
  5612. * `direction`: can be `nil`
  5613. * `right_click(clicker)`; `clicker` is another `ObjectRef`
  5614. * `get_hp()`: returns number of health points
  5615. * `set_hp(hp, reason)`: set number of health points
  5616. * See reason in register_on_player_hpchange
  5617. * Is limited to the range of 0 ... 65535 (2^16 - 1)
  5618. * For players: HP are also limited by `hp_max` specified in object properties
  5619. * `get_inventory()`: returns an `InvRef` for players, otherwise returns `nil`
  5620. * `get_wield_list()`: returns the name of the inventory list the wielded item
  5621. is in.
  5622. * `get_wield_index()`: returns the index of the wielded item
  5623. * `get_wielded_item()`: returns an `ItemStack`
  5624. * `set_wielded_item(item)`: replaces the wielded item, returns `true` if
  5625. successful.
  5626. * `set_armor_groups({group1=rating, group2=rating, ...})`
  5627. * `get_armor_groups()`: returns a table with the armor group ratings
  5628. * `set_animation(frame_range, frame_speed, frame_blend, frame_loop)`
  5629. * `frame_range`: table {x=num, y=num}, default: `{x=1, y=1}`
  5630. * `frame_speed`: number, default: `15.0`
  5631. * `frame_blend`: number, default: `0.0`
  5632. * `frame_loop`: boolean, default: `true`
  5633. * `get_animation()`: returns `range`, `frame_speed`, `frame_blend` and
  5634. `frame_loop`.
  5635. * `set_animation_frame_speed(frame_speed)`
  5636. * `frame_speed`: number, default: `15.0`
  5637. * `set_attach(parent[, bone, position, rotation, forced_visible])`
  5638. * `parent`: `ObjectRef` to attach to
  5639. * `bone`: default `""` (the root bone)
  5640. * `position`: relative position, default `{x=0, y=0, z=0}`
  5641. * `rotation`: relative rotation in degrees, default `{x=0, y=0, z=0}`
  5642. * `forced_visible`: Boolean to control whether the attached entity
  5643. should appear in first person, default `false`.
  5644. * Please also read the [Attachments] section above.
  5645. * This command may fail silently (do nothing) when it would result
  5646. in circular attachments.
  5647. * `get_attach()`: returns parent, bone, position, rotation, forced_visible,
  5648. or nil if it isn't attached.
  5649. * `get_children()`: returns a list of ObjectRefs that are attached to the
  5650. object.
  5651. * `set_detach()`
  5652. * `set_bone_position([bone, position, rotation])`
  5653. * `bone`: string. Default is `""`, the root bone
  5654. * `position`: `{x=num, y=num, z=num}`, relative, `default {x=0, y=0, z=0}`
  5655. * `rotation`: `{x=num, y=num, z=num}`, default `{x=0, y=0, z=0}`
  5656. * `get_bone_position(bone)`: returns position and rotation of the bone
  5657. * `set_properties(object property table)`
  5658. * `get_properties()`: returns object property table
  5659. * `is_player()`: returns true for players, false otherwise
  5660. * `get_nametag_attributes()`
  5661. * returns a table with the attributes of the nametag of an object
  5662. * {
  5663. text = "",
  5664. color = {a=0..255, r=0..255, g=0..255, b=0..255},
  5665. bgcolor = {a=0..255, r=0..255, g=0..255, b=0..255},
  5666. }
  5667. * `set_nametag_attributes(attributes)`
  5668. * sets the attributes of the nametag of an object
  5669. * `attributes`:
  5670. {
  5671. text = "My Nametag",
  5672. color = ColorSpec,
  5673. -- ^ Text color
  5674. bgcolor = ColorSpec or false,
  5675. -- ^ Sets background color of nametag
  5676. -- `false` will cause the background to be set automatically based on user settings
  5677. -- Default: false
  5678. }
  5679. #### Lua entity only (no-op for other objects)
  5680. * `remove()`: remove object
  5681. * The object is removed after returning from Lua. However the `ObjectRef`
  5682. itself instantly becomes unusable with all further method calls having
  5683. no effect and returning `nil`.
  5684. * `set_velocity(vel)`
  5685. * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
  5686. * `set_acceleration(acc)`
  5687. * `acc` is a vector
  5688. * `get_acceleration()`: returns the acceleration, a vector
  5689. * `set_rotation(rot)`
  5690. * `rot` is a vector (radians). X is pitch (elevation), Y is yaw (heading)
  5691. and Z is roll (bank).
  5692. * `get_rotation()`: returns the rotation, a vector (radians)
  5693. * `set_yaw(yaw)`: sets the yaw in radians (heading).
  5694. * `get_yaw()`: returns number in radians
  5695. * `set_texture_mod(mod)`
  5696. * Set a texture modifier to the base texture, for sprites and meshes.
  5697. * When calling `set_texture_mod` again, the previous one is discarded.
  5698. * `mod` the texture modifier. See [Texture modifiers].
  5699. * `get_texture_mod()` returns current texture modifier
  5700. * `set_sprite(start_frame, num_frames, framelength, select_x_by_camera)`
  5701. * Specifies and starts a sprite animation
  5702. * Animations iterate along the frame `y` position.
  5703. * `start_frame`: {x=column number, y=row number}, the coordinate of the
  5704. first frame, default: `{x=0, y=0}`
  5705. * `num_frames`: Total frames in the texture, default: `1`
  5706. * `framelength`: Time per animated frame in seconds, default: `0.2`
  5707. * `select_x_by_camera`: Only for visual = `sprite`. Changes the frame `x`
  5708. position according to the view direction. default: `false`.
  5709. * First column: subject facing the camera
  5710. * Second column: subject looking to the left
  5711. * Third column: subject backing the camera
  5712. * Fourth column: subject looking to the right
  5713. * Fifth column: subject viewed from above
  5714. * Sixth column: subject viewed from below
  5715. * `get_entity_name()` (**Deprecated**: Will be removed in a future version, use the field `self.name` instead)
  5716. * `get_luaentity()`
  5717. #### Player only (no-op for other objects)
  5718. * `get_player_name()`: returns `""` if is not a player
  5719. * `get_player_velocity()`: **DEPRECATED**, use get_velocity() instead.
  5720. table {x, y, z} representing the player's instantaneous velocity in nodes/s
  5721. * `add_player_velocity(vel)`: **DEPRECATED**, use add_velocity(vel) instead.
  5722. * `get_look_dir()`: get camera direction as a unit vector
  5723. * `get_look_vertical()`: pitch in radians
  5724. * Angle ranges between -pi/2 and pi/2, which are straight up and down
  5725. respectively.
  5726. * `get_look_horizontal()`: yaw in radians
  5727. * Angle is counter-clockwise from the +z direction.
  5728. * `set_look_vertical(radians)`: sets look pitch
  5729. * radians: Angle from looking forward, where positive is downwards.
  5730. * `set_look_horizontal(radians)`: sets look yaw
  5731. * radians: Angle from the +z direction, where positive is counter-clockwise.
  5732. * `get_look_pitch()`: pitch in radians - Deprecated as broken. Use
  5733. `get_look_vertical`.
  5734. * Angle ranges between -pi/2 and pi/2, which are straight down and up
  5735. respectively.
  5736. * `get_look_yaw()`: yaw in radians - Deprecated as broken. Use
  5737. `get_look_horizontal`.
  5738. * Angle is counter-clockwise from the +x direction.
  5739. * `set_look_pitch(radians)`: sets look pitch - Deprecated. Use
  5740. `set_look_vertical`.
  5741. * `set_look_yaw(radians)`: sets look yaw - Deprecated. Use
  5742. `set_look_horizontal`.
  5743. * `get_breath()`: returns player's breath
  5744. * `set_breath(value)`: sets player's breath
  5745. * values:
  5746. * `0`: player is drowning
  5747. * max: bubbles bar is not shown
  5748. * See [Object properties] for more information
  5749. * Is limited to range 0 ... 65535 (2^16 - 1)
  5750. * `set_fov(fov, is_multiplier, transition_time)`: Sets player's FOV
  5751. * `fov`: FOV value.
  5752. * `is_multiplier`: Set to `true` if the FOV value is a multiplier.
  5753. Defaults to `false`.
  5754. * `transition_time`: If defined, enables smooth FOV transition.
  5755. Interpreted as the time (in seconds) to reach target FOV.
  5756. If set to 0, FOV change is instantaneous. Defaults to 0.
  5757. * Set `fov` to 0 to clear FOV override.
  5758. * `get_fov()`: Returns the following:
  5759. * Server-sent FOV value. Returns 0 if an FOV override doesn't exist.
  5760. * Boolean indicating whether the FOV value is a multiplier.
  5761. * Time (in seconds) taken for the FOV transition. Set by `set_fov`.
  5762. * `set_attribute(attribute, value)`: DEPRECATED, use get_meta() instead
  5763. * Sets an extra attribute with value on player.
  5764. * `value` must be a string, or a number which will be converted to a
  5765. string.
  5766. * If `value` is `nil`, remove attribute from player.
  5767. * `get_attribute(attribute)`: DEPRECATED, use get_meta() instead
  5768. * Returns value (a string) for extra attribute.
  5769. * Returns `nil` if no attribute found.
  5770. * `get_meta()`: Returns a PlayerMetaRef.
  5771. * `set_inventory_formspec(formspec)`
  5772. * Redefine player's inventory form
  5773. * Should usually be called in `on_joinplayer`
  5774. * If `formspec` is `""`, the player's inventory is disabled.
  5775. * `get_inventory_formspec()`: returns a formspec string
  5776. * `set_formspec_prepend(formspec)`:
  5777. * the formspec string will be added to every formspec shown to the user,
  5778. except for those with a no_prepend[] tag.
  5779. * This should be used to set style elements such as background[] and
  5780. bgcolor[], any non-style elements (eg: label) may result in weird behaviour.
  5781. * Only affects formspecs shown after this is called.
  5782. * `get_formspec_prepend(formspec)`: returns a formspec string.
  5783. * `get_player_control()`: returns table with player pressed keys
  5784. * The table consists of fields with the following boolean values
  5785. representing the pressed keys: `up`, `down`, `left`, `right`, `jump`,
  5786. `aux1`, `sneak`, `dig`, `place`, `LMB`, `RMB`, and `zoom`.
  5787. * The fields `LMB` and `RMB` are equal to `dig` and `place` respectively,
  5788. and exist only to preserve backwards compatibility.
  5789. * Returns an empty table `{}` if the object is not a player.
  5790. * `get_player_control_bits()`: returns integer with bit packed player pressed
  5791. keys.
  5792. * Bits:
  5793. * 0 - up
  5794. * 1 - down
  5795. * 2 - left
  5796. * 3 - right
  5797. * 4 - jump
  5798. * 5 - aux1
  5799. * 6 - sneak
  5800. * 7 - dig
  5801. * 8 - place
  5802. * 9 - zoom
  5803. * Returns `0` (no bits set) if the object is not a player.
  5804. * `set_physics_override(override_table)`
  5805. * `override_table` is a table with the following fields:
  5806. * `speed`: multiplier to default walking speed value (default: `1`)
  5807. * `jump`: multiplier to default jump value (default: `1`)
  5808. * `gravity`: multiplier to default gravity value (default: `1`)
  5809. * `sneak`: whether player can sneak (default: `true`)
  5810. * `sneak_glitch`: whether player can use the new move code replications
  5811. of the old sneak side-effects: sneak ladders and 2 node sneak jump
  5812. (default: `false`)
  5813. * `new_move`: use new move/sneak code. When `false` the exact old code
  5814. is used for the specific old sneak behaviour (default: `true`)
  5815. * `get_physics_override()`: returns the table given to `set_physics_override`
  5816. * `hud_add(hud definition)`: add a HUD element described by HUD def, returns ID
  5817. number on success
  5818. * `hud_remove(id)`: remove the HUD element of the specified id
  5819. * `hud_change(id, stat, value)`: change a value of a previously added HUD
  5820. element.
  5821. * `stat` supports the same keys as in the hud definition table except for
  5822. `"hud_elem_type"`.
  5823. * `hud_get(id)`: gets the HUD element definition structure of the specified ID
  5824. * `hud_set_flags(flags)`: sets specified HUD flags of player.
  5825. * `flags`: A table with the following fields set to boolean values
  5826. * `hotbar`
  5827. * `healthbar`
  5828. * `crosshair`
  5829. * `wielditem`
  5830. * `breathbar`
  5831. * `minimap`: Modifies the client's permission to view the minimap.
  5832. The client may locally elect to not view the minimap.
  5833. * `minimap_radar`: is only usable when `minimap` is true
  5834. * `basic_debug`: Allow showing basic debug info that might give a gameplay advantage.
  5835. This includes map seed, player position, look direction, the pointed node and block bounds.
  5836. Does not affect players with the `debug` privilege.
  5837. * If a flag equals `nil`, the flag is not modified
  5838. * `hud_get_flags()`: returns a table of player HUD flags with boolean values.
  5839. * See `hud_set_flags` for a list of flags that can be toggled.
  5840. * `hud_set_hotbar_itemcount(count)`: sets number of items in builtin hotbar
  5841. * `count`: number of items, must be between `1` and `32`
  5842. * `hud_get_hotbar_itemcount`: returns number of visible items
  5843. * `hud_set_hotbar_image(texturename)`
  5844. * sets background image for hotbar
  5845. * `hud_get_hotbar_image`: returns texturename
  5846. * `hud_set_hotbar_selected_image(texturename)`
  5847. * sets image for selected item of hotbar
  5848. * `hud_get_hotbar_selected_image`: returns texturename
  5849. * `set_minimap_modes({mode, mode, ...}, selected_mode)`
  5850. * Overrides the available minimap modes (and toggle order), and changes the
  5851. selected mode.
  5852. * `mode` is a table consisting of up to four fields:
  5853. * `type`: Available type:
  5854. * `off`: Minimap off
  5855. * `surface`: Minimap in surface mode
  5856. * `radar`: Minimap in radar mode
  5857. * `texture`: Texture to be displayed instead of terrain map
  5858. (texture is centered around 0,0 and can be scaled).
  5859. Texture size is limited to 512 x 512 pixel.
  5860. * `label`: Optional label to display on minimap mode toggle
  5861. The translation must be handled within the mod.
  5862. * `size`: Sidelength or diameter, in number of nodes, of the terrain
  5863. displayed in minimap
  5864. * `texture`: Only for texture type, name of the texture to display
  5865. * `scale`: Only for texture type, scale of the texture map in nodes per
  5866. pixel (for example a `scale` of 2 means each pixel represents a 2x2
  5867. nodes square)
  5868. * `selected_mode` is the mode index to be selected after modes have been changed
  5869. (0 is the first mode).
  5870. * `set_sky(sky_parameters)`
  5871. * The presence of the function `set_sun`, `set_moon` or `set_stars` indicates
  5872. whether `set_sky` accepts this format. Check the legacy format otherwise.
  5873. * Passing no arguments resets the sky to its default values.
  5874. * `sky_parameters` is a table with the following optional fields:
  5875. * `base_color`: ColorSpec, changes fog in "skybox" and "plain".
  5876. (default: `#ffffff`)
  5877. * `type`: Available types:
  5878. * `"regular"`: Uses 0 textures, `base_color` ignored
  5879. * `"skybox"`: Uses 6 textures, `base_color` used as fog.
  5880. * `"plain"`: Uses 0 textures, `base_color` used as both fog and sky.
  5881. (default: `"regular"`)
  5882. * `textures`: A table containing up to six textures in the following
  5883. order: Y+ (top), Y- (bottom), X- (west), X+ (east), Z+ (north), Z- (south).
  5884. * `clouds`: Boolean for whether clouds appear. (default: `true`)
  5885. * `sky_color`: A table used in `"regular"` type only, containing the
  5886. following values (alpha is ignored):
  5887. * `day_sky`: ColorSpec, for the top half of the sky during the day.
  5888. (default: `#61b5f5`)
  5889. * `day_horizon`: ColorSpec, for the bottom half of the sky during the day.
  5890. (default: `#90d3f6`)
  5891. * `dawn_sky`: ColorSpec, for the top half of the sky during dawn/sunset.
  5892. (default: `#b4bafa`)
  5893. The resulting sky color will be a darkened version of the ColorSpec.
  5894. Warning: The darkening of the ColorSpec is subject to change.
  5895. * `dawn_horizon`: ColorSpec, for the bottom half of the sky during dawn/sunset.
  5896. (default: `#bac1f0`)
  5897. The resulting sky color will be a darkened version of the ColorSpec.
  5898. Warning: The darkening of the ColorSpec is subject to change.
  5899. * `night_sky`: ColorSpec, for the top half of the sky during the night.
  5900. (default: `#006bff`)
  5901. The resulting sky color will be a dark version of the ColorSpec.
  5902. Warning: The darkening of the ColorSpec is subject to change.
  5903. * `night_horizon`: ColorSpec, for the bottom half of the sky during the night.
  5904. (default: `#4090ff`)
  5905. The resulting sky color will be a dark version of the ColorSpec.
  5906. Warning: The darkening of the ColorSpec is subject to change.
  5907. * `indoors`: ColorSpec, for when you're either indoors or underground.
  5908. (default: `#646464`)
  5909. * `fog_sun_tint`: ColorSpec, changes the fog tinting for the sun
  5910. at sunrise and sunset. (default: `#f47d1d`)
  5911. * `fog_moon_tint`: ColorSpec, changes the fog tinting for the moon
  5912. at sunrise and sunset. (default: `#7f99cc`)
  5913. * `fog_tint_type`: string, changes which mode the directional fog
  5914. abides by, `"custom"` uses `sun_tint` and `moon_tint`, while
  5915. `"default"` uses the classic Minetest sun and moon tinting.
  5916. Will use tonemaps, if set to `"default"`. (default: `"default"`)
  5917. * `set_sky(base_color, type, {texture names}, clouds)`
  5918. * Deprecated. Use `set_sky(sky_parameters)`
  5919. * `base_color`: ColorSpec, defaults to white
  5920. * `type`: Available types:
  5921. * `"regular"`: Uses 0 textures, `bgcolor` ignored
  5922. * `"skybox"`: Uses 6 textures, `bgcolor` used
  5923. * `"plain"`: Uses 0 textures, `bgcolor` used
  5924. * `clouds`: Boolean for whether clouds appear in front of `"skybox"` or
  5925. `"plain"` custom skyboxes (default: `true`)
  5926. * `get_sky(as_table)`:
  5927. * `as_table`: boolean that determines whether the deprecated version of this
  5928. function is being used.
  5929. * `true` returns a table containing sky parameters as defined in `set_sky(sky_parameters)`.
  5930. * Deprecated: `false` or `nil` returns base_color, type, table of textures,
  5931. clouds.
  5932. * `get_sky_color()`:
  5933. * Deprecated: Use `get_sky(as_table)` instead.
  5934. * returns a table with the `sky_color` parameters as in `set_sky`.
  5935. * `set_sun(sun_parameters)`:
  5936. * Passing no arguments resets the sun to its default values.
  5937. * `sun_parameters` is a table with the following optional fields:
  5938. * `visible`: Boolean for whether the sun is visible.
  5939. (default: `true`)
  5940. * `texture`: A regular texture for the sun. Setting to `""`
  5941. will re-enable the mesh sun. (default: "sun.png", if it exists)
  5942. * `tonemap`: A 512x1 texture containing the tonemap for the sun
  5943. (default: `"sun_tonemap.png"`)
  5944. * `sunrise`: A regular texture for the sunrise texture.
  5945. (default: `"sunrisebg.png"`)
  5946. * `sunrise_visible`: Boolean for whether the sunrise texture is visible.
  5947. (default: `true`)
  5948. * `scale`: Float controlling the overall size of the sun. (default: `1`)
  5949. * `get_sun()`: returns a table with the current sun parameters as in
  5950. `set_sun`.
  5951. * `set_moon(moon_parameters)`:
  5952. * Passing no arguments resets the moon to its default values.
  5953. * `moon_parameters` is a table with the following optional fields:
  5954. * `visible`: Boolean for whether the moon is visible.
  5955. (default: `true`)
  5956. * `texture`: A regular texture for the moon. Setting to `""`
  5957. will re-enable the mesh moon. (default: `"moon.png"`, if it exists)
  5958. Note: Relative to the sun, the moon texture is rotated by 180°.
  5959. You can use the `^[transformR180` texture modifier to achieve the same orientation.
  5960. * `tonemap`: A 512x1 texture containing the tonemap for the moon
  5961. (default: `"moon_tonemap.png"`)
  5962. * `scale`: Float controlling the overall size of the moon (default: `1`)
  5963. * `get_moon()`: returns a table with the current moon parameters as in
  5964. `set_moon`.
  5965. * `set_stars(star_parameters)`:
  5966. * Passing no arguments resets stars to their default values.
  5967. * `star_parameters` is a table with the following optional fields:
  5968. * `visible`: Boolean for whether the stars are visible.
  5969. (default: `true`)
  5970. * `day_opacity`: Float for maximum opacity of stars at day.
  5971. No effect if `visible` is false.
  5972. (default: 0.0; maximum: 1.0; minimum: 0.0)
  5973. * `count`: Integer number to set the number of stars in
  5974. the skybox. Only applies to `"skybox"` and `"regular"` sky types.
  5975. (default: `1000`)
  5976. * `star_color`: ColorSpec, sets the colors of the stars,
  5977. alpha channel is used to set overall star brightness.
  5978. (default: `#ebebff69`)
  5979. * `scale`: Float controlling the overall size of the stars (default: `1`)
  5980. * `get_stars()`: returns a table with the current stars parameters as in
  5981. `set_stars`.
  5982. * `set_clouds(cloud_parameters)`: set cloud parameters
  5983. * Passing no arguments resets clouds to their default values.
  5984. * `cloud_parameters` is a table with the following optional fields:
  5985. * `density`: from `0` (no clouds) to `1` (full clouds) (default `0.4`)
  5986. * `color`: basic cloud color with alpha channel, ColorSpec
  5987. (default `#fff0f0e5`).
  5988. * `ambient`: cloud color lower bound, use for a "glow at night" effect.
  5989. ColorSpec (alpha ignored, default `#000000`)
  5990. * `height`: cloud height, i.e. y of cloud base (default per conf,
  5991. usually `120`)
  5992. * `thickness`: cloud thickness in nodes (default `16`)
  5993. * `speed`: 2D cloud speed + direction in nodes per second
  5994. (default `{x=0, z=-2}`).
  5995. * `get_clouds()`: returns a table with the current cloud parameters as in
  5996. `set_clouds`.
  5997. * `override_day_night_ratio(ratio or nil)`
  5998. * `0`...`1`: Overrides day-night ratio, controlling sunlight to a specific
  5999. amount.
  6000. * `nil`: Disables override, defaulting to sunlight based on day-night cycle
  6001. * `get_day_night_ratio()`: returns the ratio or nil if it isn't overridden
  6002. * `set_local_animation(idle, walk, dig, walk_while_dig, frame_speed)`:
  6003. set animation for player model in third person view.
  6004. * Every animation equals to a `{x=starting frame, y=ending frame}` table.
  6005. * `frame_speed` sets the animations frame speed. Default is 30.
  6006. * `get_local_animation()`: returns idle, walk, dig, walk_while_dig tables and
  6007. `frame_speed`.
  6008. * `set_eye_offset([firstperson, thirdperson])`: defines offset vectors for
  6009. camera per player. An argument defaults to `{x=0, y=0, z=0}` if unspecified.
  6010. * in first person view
  6011. * in third person view (max. values `{x=-10/10,y=-10,15,z=-5/5}`)
  6012. * `get_eye_offset()`: returns first and third person offsets.
  6013. * `send_mapblock(blockpos)`:
  6014. * Sends an already loaded mapblock to the player.
  6015. * Returns `false` if nothing was sent (note that this can also mean that
  6016. the client already has the block)
  6017. * Resource intensive - use sparsely
  6018. * `set_lighting(light_definition)`: sets lighting for the player
  6019. * `light_definition` is a table with the following optional fields:
  6020. * `shadows` is a table that controls ambient shadows
  6021. * `intensity` sets the intensity of the shadows from 0 (no shadows, default) to 1 (blackness)
  6022. * `get_lighting()`: returns the current state of lighting for the player.
  6023. * Result is a table with the same fields as `light_definition` in `set_lighting`.
  6024. * `respawn()`: Respawns the player using the same mechanism as the death screen,
  6025. including calling on_respawnplayer callbacks.
  6026. `PcgRandom`
  6027. -----------
  6028. A 32-bit pseudorandom number generator.
  6029. Uses PCG32, an algorithm of the permuted congruential generator family,
  6030. offering very strong randomness.
  6031. It can be created via `PcgRandom(seed)` or `PcgRandom(seed, sequence)`.
  6032. ### Methods
  6033. * `next()`: return next integer random number [`-2147483648`...`2147483647`]
  6034. * `next(min, max)`: return next integer random number [`min`...`max`]
  6035. * `rand_normal_dist(min, max, num_trials=6)`: return normally distributed
  6036. random number [`min`...`max`].
  6037. * This is only a rough approximation of a normal distribution with:
  6038. * `mean = (max - min) / 2`, and
  6039. * `variance = (((max - min + 1) ^ 2) - 1) / (12 * num_trials)`
  6040. * Increasing `num_trials` improves accuracy of the approximation
  6041. `PerlinNoise`
  6042. -------------
  6043. A perlin noise generator.
  6044. It can be created via `PerlinNoise()` or `minetest.get_perlin()`.
  6045. For `minetest.get_perlin()`, the actual seed used is the noiseparams seed
  6046. plus the world seed, to create world-specific noise.
  6047. `PerlinNoise(noiseparams)`
  6048. `PerlinNoise(seed, octaves, persistence, spread)` (Deprecated).
  6049. `minetest.get_perlin(noiseparams)`
  6050. `minetest.get_perlin(seeddiff, octaves, persistence, spread)` (Deprecated).
  6051. ### Methods
  6052. * `get_2d(pos)`: returns 2D noise value at `pos={x=,y=}`
  6053. * `get_3d(pos)`: returns 3D noise value at `pos={x=,y=,z=}`
  6054. `PerlinNoiseMap`
  6055. ----------------
  6056. A fast, bulk perlin noise generator.
  6057. It can be created via `PerlinNoiseMap(noiseparams, size)` or
  6058. `minetest.get_perlin_map(noiseparams, size)`.
  6059. For `minetest.get_perlin_map()`, the actual seed used is the noiseparams seed
  6060. plus the world seed, to create world-specific noise.
  6061. Format of `size` is `{x=dimx, y=dimy, z=dimz}`. The `z` component is omitted
  6062. for 2D noise, and it must be must be larger than 1 for 3D noise (otherwise
  6063. `nil` is returned).
  6064. For each of the functions with an optional `buffer` parameter: If `buffer` is
  6065. not nil, this table will be used to store the result instead of creating a new
  6066. table.
  6067. ### Methods
  6068. * `get_2d_map(pos)`: returns a `<size.x>` times `<size.y>` 2D array of 2D noise
  6069. with values starting at `pos={x=,y=}`
  6070. * `get_3d_map(pos)`: returns a `<size.x>` times `<size.y>` times `<size.z>`
  6071. 3D array of 3D noise with values starting at `pos={x=,y=,z=}`.
  6072. * `get_2d_map_flat(pos, buffer)`: returns a flat `<size.x * size.y>` element
  6073. array of 2D noise with values starting at `pos={x=,y=}`
  6074. * `get_3d_map_flat(pos, buffer)`: Same as `get2dMap_flat`, but 3D noise
  6075. * `calc_2d_map(pos)`: Calculates the 2d noise map starting at `pos`. The result
  6076. is stored internally.
  6077. * `calc_3d_map(pos)`: Calculates the 3d noise map starting at `pos`. The result
  6078. is stored internally.
  6079. * `get_map_slice(slice_offset, slice_size, buffer)`: In the form of an array,
  6080. returns a slice of the most recently computed noise results. The result slice
  6081. begins at coordinates `slice_offset` and takes a chunk of `slice_size`.
  6082. E.g. to grab a 2-slice high horizontal 2d plane of noise starting at buffer
  6083. offset y = 20:
  6084. `noisevals = noise:get_map_slice({y=20}, {y=2})`
  6085. It is important to note that `slice_offset` offset coordinates begin at 1,
  6086. and are relative to the starting position of the most recently calculated
  6087. noise.
  6088. To grab a single vertical column of noise starting at map coordinates
  6089. x = 1023, y=1000, z = 1000:
  6090. `noise:calc_3d_map({x=1000, y=1000, z=1000})`
  6091. `noisevals = noise:get_map_slice({x=24, z=1}, {x=1, z=1})`
  6092. `PlayerMetaRef`
  6093. ---------------
  6094. Player metadata.
  6095. Uses the same method of storage as the deprecated player attribute API, so
  6096. data there will also be in player meta.
  6097. Can be obtained using `player:get_meta()`.
  6098. ### Methods
  6099. * All methods in MetaDataRef
  6100. `PseudoRandom`
  6101. --------------
  6102. A 16-bit pseudorandom number generator.
  6103. Uses a well-known LCG algorithm introduced by K&R.
  6104. It can be created via `PseudoRandom(seed)`.
  6105. ### Methods
  6106. * `next()`: return next integer random number [`0`...`32767`]
  6107. * `next(min, max)`: return next integer random number [`min`...`max`]
  6108. * `((max - min) == 32767) or ((max-min) <= 6553))` must be true
  6109. due to the simple implementation making bad distribution otherwise.
  6110. `Raycast`
  6111. ---------
  6112. A raycast on the map. It works with selection boxes.
  6113. Can be used as an iterator in a for loop as:
  6114. local ray = Raycast(...)
  6115. for pointed_thing in ray do
  6116. ...
  6117. end
  6118. The map is loaded as the ray advances. If the map is modified after the
  6119. `Raycast` is created, the changes may or may not have an effect on the object.
  6120. It can be created via `Raycast(pos1, pos2, objects, liquids)` or
  6121. `minetest.raycast(pos1, pos2, objects, liquids)` where:
  6122. * `pos1`: start of the ray
  6123. * `pos2`: end of the ray
  6124. * `objects`: if false, only nodes will be returned. Default is true.
  6125. * `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
  6126. returned. Default is false.
  6127. ### Methods
  6128. * `next()`: returns a `pointed_thing` with exact pointing location
  6129. * Returns the next thing pointed by the ray or nil.
  6130. `SecureRandom`
  6131. --------------
  6132. Interface for the operating system's crypto-secure PRNG.
  6133. It can be created via `SecureRandom()`. The constructor returns nil if a
  6134. secure random device cannot be found on the system.
  6135. ### Methods
  6136. * `next_bytes([count])`: return next `count` (default 1, capped at 2048) many
  6137. random bytes, as a string.
  6138. `Settings`
  6139. ----------
  6140. An interface to read config files in the format of `minetest.conf`.
  6141. It can be created via `Settings(filename)`.
  6142. ### Methods
  6143. * `get(key)`: returns a value
  6144. * `get_bool(key, [default])`: returns a boolean
  6145. * `default` is the value returned if `key` is not found.
  6146. * Returns `nil` if `key` is not found and `default` not specified.
  6147. * `get_np_group(key)`: returns a NoiseParams table
  6148. * `get_flags(key)`:
  6149. * Returns `{flag = true/false, ...}` according to the set flags.
  6150. * Is currently limited to mapgen flags `mg_flags` and mapgen-specific
  6151. flags like `mgv5_spflags`.
  6152. * `set(key, value)`
  6153. * Setting names can't contain whitespace or any of `="{}#`.
  6154. * Setting values can't contain the sequence `\n"""`.
  6155. * Setting names starting with "secure." can't be set on the main settings
  6156. object (`minetest.settings`).
  6157. * `set_bool(key, value)`
  6158. * See documentation for set() above.
  6159. * `set_np_group(key, value)`
  6160. * `value` is a NoiseParams table.
  6161. * Also, see documentation for set() above.
  6162. * `remove(key)`: returns a boolean (`true` for success)
  6163. * `get_names()`: returns `{key1,...}`
  6164. * `write()`: returns a boolean (`true` for success)
  6165. * Writes changes to file.
  6166. * `to_table()`: returns `{[key1]=value1,...}`
  6167. ### Format
  6168. The settings have the format `key = value`. Example:
  6169. foo = example text
  6170. bar = """
  6171. Multiline
  6172. value
  6173. """
  6174. `StorageRef`
  6175. ------------
  6176. Mod metadata: per mod metadata, saved automatically.
  6177. Can be obtained via `minetest.get_mod_storage()` during load time.
  6178. WARNING: This storage backend is incapable of saving raw binary data due
  6179. to restrictions of JSON.
  6180. ### Methods
  6181. * All methods in MetaDataRef
  6182. Definition tables
  6183. =================
  6184. Object properties
  6185. -----------------
  6186. Used by `ObjectRef` methods. Part of an Entity definition.
  6187. These properties are not persistent, but are applied automatically to the
  6188. corresponding Lua entity using the given registration fields.
  6189. Player properties need to be saved manually.
  6190. {
  6191. hp_max = 10,
  6192. -- Defines the maximum and default HP of the entity
  6193. -- For Lua entities the maximum is not enforced.
  6194. -- For players this defaults to `minetest.PLAYER_MAX_HP_DEFAULT`.
  6195. breath_max = 0,
  6196. -- For players only. Defaults to `minetest.PLAYER_MAX_BREATH_DEFAULT`.
  6197. zoom_fov = 0.0,
  6198. -- For players only. Zoom FOV in degrees.
  6199. -- Note that zoom loads and/or generates world beyond the server's
  6200. -- maximum send and generate distances, so acts like a telescope.
  6201. -- Smaller zoom_fov values increase the distance loaded/generated.
  6202. -- Defaults to 15 in creative mode, 0 in survival mode.
  6203. -- zoom_fov = 0 disables zooming for the player.
  6204. eye_height = 1.625,
  6205. -- For players only. Camera height above feet position in nodes.
  6206. physical = false,
  6207. -- Collide with `walkable` nodes.
  6208. collide_with_objects = true,
  6209. -- Collide with other objects if physical = true
  6210. collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  6211. selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  6212. -- Selection box uses collision box dimensions when not set.
  6213. -- For both boxes: {xmin, ymin, zmin, xmax, ymax, zmax} in nodes from
  6214. -- object position.
  6215. pointable = true,
  6216. -- Whether the object can be pointed at
  6217. visual = "cube" / "sprite" / "upright_sprite" / "mesh" / "wielditem" / "item",
  6218. -- "cube" is a node-sized cube.
  6219. -- "sprite" is a flat texture always facing the player.
  6220. -- "upright_sprite" is a vertical flat texture.
  6221. -- "mesh" uses the defined mesh model.
  6222. -- "wielditem" is used for dropped items.
  6223. -- (see builtin/game/item_entity.lua).
  6224. -- For this use 'wield_item = itemname' (Deprecated: 'textures = {itemname}').
  6225. -- If the item has a 'wield_image' the object will be an extrusion of
  6226. -- that, otherwise:
  6227. -- If 'itemname' is a cubic node or nodebox the object will appear
  6228. -- identical to 'itemname'.
  6229. -- If 'itemname' is a plantlike node the object will be an extrusion
  6230. -- of its texture.
  6231. -- Otherwise for non-node items, the object will be an extrusion of
  6232. -- 'inventory_image'.
  6233. -- If 'itemname' contains a ColorString or palette index (e.g. from
  6234. -- `minetest.itemstring_with_palette()`), the entity will inherit the color.
  6235. -- "item" is similar to "wielditem" but ignores the 'wield_image' parameter.
  6236. visual_size = {x = 1, y = 1, z = 1},
  6237. -- Multipliers for the visual size. If `z` is not specified, `x` will be used
  6238. -- to scale the entity along both horizontal axes.
  6239. mesh = "model.obj",
  6240. -- File name of mesh when using "mesh" visual
  6241. textures = {},
  6242. -- Number of required textures depends on visual.
  6243. -- "cube" uses 6 textures just like a node, but all 6 must be defined.
  6244. -- "sprite" uses 1 texture.
  6245. -- "upright_sprite" uses 2 textures: {front, back}.
  6246. -- "wielditem" expects 'textures = {itemname}' (see 'visual' above).
  6247. -- "mesh" requires one texture for each mesh buffer/material (in order)
  6248. colors = {},
  6249. -- Number of required colors depends on visual
  6250. use_texture_alpha = false,
  6251. -- Use texture's alpha channel.
  6252. -- Excludes "upright_sprite" and "wielditem".
  6253. -- Note: currently causes visual issues when viewed through other
  6254. -- semi-transparent materials such as water.
  6255. spritediv = {x = 1, y = 1},
  6256. -- Used with spritesheet textures for animation and/or frame selection
  6257. -- according to position relative to player.
  6258. -- Defines the number of columns and rows in the spritesheet:
  6259. -- {columns, rows}.
  6260. initial_sprite_basepos = {x = 0, y = 0},
  6261. -- Used with spritesheet textures.
  6262. -- Defines the {column, row} position of the initially used frame in the
  6263. -- spritesheet.
  6264. is_visible = true,
  6265. -- If false, object is invisible and can't be pointed.
  6266. makes_footstep_sound = false,
  6267. -- If true, is able to make footstep sounds of nodes
  6268. -- (see node sound definition for details).
  6269. automatic_rotate = 0,
  6270. -- Set constant rotation in radians per second, positive or negative.
  6271. -- Object rotates along the local Y-axis, and works with set_rotation.
  6272. -- Set to 0 to disable constant rotation.
  6273. stepheight = 0,
  6274. -- If positive number, object will climb upwards when it moves
  6275. -- horizontally against a `walkable` node, if the height difference
  6276. -- is within `stepheight`.
  6277. automatic_face_movement_dir = 0.0,
  6278. -- Automatically set yaw to movement direction, offset in degrees.
  6279. -- 'false' to disable.
  6280. automatic_face_movement_max_rotation_per_sec = -1,
  6281. -- Limit automatic rotation to this value in degrees per second.
  6282. -- No limit if value <= 0.
  6283. backface_culling = true,
  6284. -- Set to false to disable backface_culling for model
  6285. glow = 0,
  6286. -- Add this much extra lighting when calculating texture color.
  6287. -- Value < 0 disables light's effect on texture color.
  6288. -- For faking self-lighting, UI style entities, or programmatic coloring
  6289. -- in mods.
  6290. nametag = "",
  6291. -- The name to display on the head of the object. By default empty.
  6292. -- If the object is a player, a nil or empty nametag is replaced by the player's name.
  6293. -- For all other objects, a nil or empty string removes the nametag.
  6294. -- To hide a nametag, set its color alpha to zero. That will disable it entirely.
  6295. nametag_color = <ColorSpec>,
  6296. -- Sets text color of nametag
  6297. nametag_bgcolor = <ColorSpec>,
  6298. -- Sets background color of nametag
  6299. -- `false` will cause the background to be set automatically based on user settings.
  6300. -- Default: false
  6301. infotext = "",
  6302. -- Same as infotext for nodes. Empty by default
  6303. static_save = true,
  6304. -- If false, never save this object statically. It will simply be
  6305. -- deleted when the block gets unloaded.
  6306. -- The get_staticdata() callback is never called then.
  6307. -- Defaults to 'true'.
  6308. damage_texture_modifier = "^[brighten",
  6309. -- Texture modifier to be applied for a short duration when object is hit
  6310. shaded = true,
  6311. -- Setting this to 'false' disables diffuse lighting of entity
  6312. show_on_minimap = false,
  6313. -- Defaults to true for players, false for other entities.
  6314. -- If set to true the entity will show as a marker on the minimap.
  6315. }
  6316. Entity definition
  6317. -----------------
  6318. Used by `minetest.register_entity`.
  6319. {
  6320. initial_properties = {
  6321. visual = "mesh",
  6322. mesh = "boats_boat.obj",
  6323. ...,
  6324. },
  6325. -- A table of object properties, see the `Object properties` section.
  6326. -- The properties in this table are applied to the object
  6327. -- once when it is spawned.
  6328. -- Refer to the "Registered entities" section for explanations
  6329. on_activate = function(self, staticdata, dtime_s),
  6330. on_deactivate = function(self, removal),
  6331. on_step = function(self, dtime, moveresult),
  6332. on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage),
  6333. on_death = function(self, killer),
  6334. on_rightclick = function(self, clicker),
  6335. on_attach_child = function(self, child),
  6336. on_detach_child = function(self, child),
  6337. on_detach = function(self, parent),
  6338. get_staticdata = function(self),
  6339. _custom_field = whatever,
  6340. -- You can define arbitrary member variables here (see Item definition
  6341. -- for more info) by using a '_' prefix
  6342. }
  6343. ABM (ActiveBlockModifier) definition
  6344. ------------------------------------
  6345. Used by `minetest.register_abm`.
  6346. {
  6347. label = "Lava cooling",
  6348. -- Descriptive label for profiling purposes (optional).
  6349. -- Definitions with identical labels will be listed as one.
  6350. nodenames = {"default:lava_source"},
  6351. -- Apply `action` function to these nodes.
  6352. -- `group:groupname` can also be used here.
  6353. neighbors = {"default:water_source", "default:water_flowing"},
  6354. -- Only apply `action` to nodes that have one of, or any
  6355. -- combination of, these neighbors.
  6356. -- If left out or empty, any neighbor will do.
  6357. -- `group:groupname` can also be used here.
  6358. interval = 1.0,
  6359. -- Operation interval in seconds
  6360. chance = 1,
  6361. -- Chance of triggering `action` per-node per-interval is 1.0 / this
  6362. -- value
  6363. min_y = -32768,
  6364. max_y = 32767,
  6365. -- min and max height levels where ABM will be processed (inclusive)
  6366. -- can be used to reduce CPU usage
  6367. catch_up = true,
  6368. -- If true, catch-up behaviour is enabled: The `chance` value is
  6369. -- temporarily reduced when returning to an area to simulate time lost
  6370. -- by the area being unattended. Note that the `chance` value can often
  6371. -- be reduced to 1.
  6372. action = function(pos, node, active_object_count, active_object_count_wider),
  6373. -- Function triggered for each qualifying node.
  6374. -- `active_object_count` is number of active objects in the node's
  6375. -- mapblock.
  6376. -- `active_object_count_wider` is number of active objects in the node's
  6377. -- mapblock plus all 26 neighboring mapblocks. If any neighboring
  6378. -- mapblocks are unloaded an estmate is calculated for them based on
  6379. -- loaded mapblocks.
  6380. }
  6381. LBM (LoadingBlockModifier) definition
  6382. -------------------------------------
  6383. Used by `minetest.register_lbm`.
  6384. A loading block modifier (LBM) is used to define a function that is called for
  6385. specific nodes (defined by `nodenames`) when a mapblock which contains such nodes
  6386. gets activated (not loaded!)
  6387. {
  6388. label = "Upgrade legacy doors",
  6389. -- Descriptive label for profiling purposes (optional).
  6390. -- Definitions with identical labels will be listed as one.
  6391. name = "modname:replace_legacy_door",
  6392. -- Identifier of the LBM, should follow the modname:<whatever> convention
  6393. nodenames = {"default:lava_source"},
  6394. -- List of node names to trigger the LBM on.
  6395. -- Names of non-registered nodes and groups (as group:groupname)
  6396. -- will work as well.
  6397. run_at_every_load = false,
  6398. -- Whether to run the LBM's action every time a block gets activated,
  6399. -- and not only the first time the block gets activated after the LBM
  6400. -- was introduced.
  6401. action = function(pos, node),
  6402. -- Function triggered for each qualifying node.
  6403. }
  6404. Tile definition
  6405. ---------------
  6406. * `"image.png"`
  6407. * `{name="image.png", animation={Tile Animation definition}}`
  6408. * `{name="image.png", backface_culling=bool, align_style="node"/"world"/"user", scale=int}`
  6409. * backface culling enabled by default for most nodes
  6410. * align style determines whether the texture will be rotated with the node
  6411. or kept aligned with its surroundings. "user" means that client
  6412. setting will be used, similar to `glasslike_framed_optional`.
  6413. Note: supported by solid nodes and nodeboxes only.
  6414. * scale is used to make texture span several (exactly `scale`) nodes,
  6415. instead of just one, in each direction. Works for world-aligned
  6416. textures only.
  6417. Note that as the effect is applied on per-mapblock basis, `16` should
  6418. be equally divisible by `scale` or you may get wrong results.
  6419. * `{name="image.png", color=ColorSpec}`
  6420. * the texture's color will be multiplied with this color.
  6421. * the tile's color overrides the owning node's color in all cases.
  6422. * deprecated, yet still supported field names:
  6423. * `image` (name)
  6424. Tile animation definition
  6425. -------------------------
  6426. {
  6427. type = "vertical_frames",
  6428. aspect_w = 16,
  6429. -- Width of a frame in pixels
  6430. aspect_h = 16,
  6431. -- Height of a frame in pixels
  6432. length = 3.0,
  6433. -- Full loop length
  6434. }
  6435. {
  6436. type = "sheet_2d",
  6437. frames_w = 5,
  6438. -- Width in number of frames
  6439. frames_h = 3,
  6440. -- Height in number of frames
  6441. frame_length = 0.5,
  6442. -- Length of a single frame
  6443. }
  6444. Item definition
  6445. ---------------
  6446. Used by `minetest.register_node`, `minetest.register_craftitem`, and
  6447. `minetest.register_tool`.
  6448. {
  6449. description = "",
  6450. -- Can contain new lines. "\n" has to be used as new line character.
  6451. -- See also: `get_description` in [`ItemStack`]
  6452. short_description = "",
  6453. -- Must not contain new lines.
  6454. -- Defaults to nil.
  6455. -- Use an [`ItemStack`] to get the short description, e.g.:
  6456. -- ItemStack(itemname):get_short_description()
  6457. groups = {},
  6458. -- key = name, value = rating; rating = <number>.
  6459. -- If rating not applicable, use 1.
  6460. -- e.g. {wool = 1, fluffy = 3}
  6461. -- {soil = 2, outerspace = 1, crumbly = 1}
  6462. -- {bendy = 2, snappy = 1},
  6463. -- {hard = 1, metal = 1, spikes = 1}
  6464. inventory_image = "",
  6465. -- Texture shown in the inventory GUI
  6466. -- Defaults to a 3D rendering of the node if left empty.
  6467. inventory_overlay = "",
  6468. -- An overlay texture which is not affected by colorization
  6469. wield_image = "",
  6470. -- Texture shown when item is held in hand
  6471. -- Defaults to a 3D rendering of the node if left empty.
  6472. wield_overlay = "",
  6473. -- Like inventory_overlay but only used in the same situation as wield_image
  6474. wield_scale = {x = 1, y = 1, z = 1},
  6475. -- Scale for the item when held in hand
  6476. palette = "",
  6477. -- An image file containing the palette of a node.
  6478. -- You can set the currently used color as the "palette_index" field of
  6479. -- the item stack metadata.
  6480. -- The palette is always stretched to fit indices between 0 and 255, to
  6481. -- ensure compatibility with "colorfacedir" and "colorwallmounted" nodes.
  6482. color = "#ffffffff",
  6483. -- Color the item is colorized with. The palette overrides this.
  6484. stack_max = 99,
  6485. -- Maximum amount of items that can be in a single stack.
  6486. -- The default can be changed by the setting `default_stack_max`
  6487. range = 4.0,
  6488. -- Range of node and object pointing that is possible with this item held
  6489. liquids_pointable = false,
  6490. -- If true, item can point to all liquid nodes (`liquidtype ~= "none"`),
  6491. -- even those for which `pointable = false`
  6492. light_source = 0,
  6493. -- When used for nodes: Defines amount of light emitted by node.
  6494. -- Otherwise: Defines texture glow when viewed as a dropped item
  6495. -- To set the maximum (14), use the value 'minetest.LIGHT_MAX'.
  6496. -- A value outside the range 0 to minetest.LIGHT_MAX causes undefined
  6497. -- behavior.
  6498. -- See "Tool Capabilities" section for an example including explanation
  6499. tool_capabilities = {
  6500. full_punch_interval = 1.0,
  6501. max_drop_level = 0,
  6502. groupcaps = {
  6503. -- For example:
  6504. choppy = {times = {2.50, 1.40, 1.00}, uses = 20, maxlevel = 2},
  6505. },
  6506. damage_groups = {groupname = damage},
  6507. -- Damage values must be between -32768 and 32767 (2^15)
  6508. punch_attack_uses = nil,
  6509. -- Amount of uses this tool has for attacking players and entities
  6510. -- by punching them (0 = infinite uses).
  6511. -- For compatibility, this is automatically set from the first
  6512. -- suitable groupcap using the forumla "uses * 3^(maxlevel - 1)".
  6513. -- It is recommend to set this explicitly instead of relying on the
  6514. -- fallback behavior.
  6515. },
  6516. node_placement_prediction = nil,
  6517. -- If nil and item is node, prediction is made automatically.
  6518. -- If nil and item is not a node, no prediction is made.
  6519. -- If "" and item is anything, no prediction is made.
  6520. -- Otherwise should be name of node which the client immediately places
  6521. -- on ground when the player places the item. Server will always update
  6522. -- with actual result shortly.
  6523. node_dig_prediction = "air",
  6524. -- if "", no prediction is made.
  6525. -- if "air", node is removed.
  6526. -- Otherwise should be name of node which the client immediately places
  6527. -- upon digging. Server will always update with actual result shortly.
  6528. sound = {
  6529. -- Definition of item sounds to be played at various events.
  6530. -- All fields in this table are optional.
  6531. breaks = <SimpleSoundSpec>,
  6532. -- When tool breaks due to wear. Ignored for non-tools
  6533. eat = <SimpleSoundSpec>,
  6534. -- When item is eaten with `minetest.do_item_eat`
  6535. },
  6536. on_place = function(itemstack, placer, pointed_thing),
  6537. -- When the 'place' key was pressed with the item in hand
  6538. -- and a node was pointed at.
  6539. -- Shall place item and return the leftover itemstack
  6540. -- or nil to not modify the inventory.
  6541. -- The placer may be any ObjectRef or nil.
  6542. -- default: minetest.item_place
  6543. on_secondary_use = function(itemstack, user, pointed_thing),
  6544. -- Same as on_place but called when not pointing at a node.
  6545. -- Function must return either nil if inventory shall not be modified,
  6546. -- or an itemstack to replace the original itemstack.
  6547. -- The user may be any ObjectRef or nil.
  6548. -- default: nil
  6549. on_drop = function(itemstack, dropper, pos),
  6550. -- Shall drop item and return the leftover itemstack.
  6551. -- The dropper may be any ObjectRef or nil.
  6552. -- default: minetest.item_drop
  6553. on_use = function(itemstack, user, pointed_thing),
  6554. -- default: nil
  6555. -- When user pressed the 'punch/mine' key with the item in hand.
  6556. -- Function must return either nil if inventory shall not be modified,
  6557. -- or an itemstack to replace the original itemstack.
  6558. -- e.g. itemstack:take_item(); return itemstack
  6559. -- Otherwise, the function is free to do what it wants.
  6560. -- The user may be any ObjectRef or nil.
  6561. -- The default functions handle regular use cases.
  6562. after_use = function(itemstack, user, node, digparams),
  6563. -- default: nil
  6564. -- If defined, should return an itemstack and will be called instead of
  6565. -- wearing out the item (if tool). If returns nil, does nothing.
  6566. -- If after_use doesn't exist, it is the same as:
  6567. -- function(itemstack, user, node, digparams)
  6568. -- itemstack:add_wear(digparams.wear)
  6569. -- return itemstack
  6570. -- end
  6571. -- The user may be any ObjectRef or nil.
  6572. _custom_field = whatever,
  6573. -- Add your own custom fields. By convention, all custom field names
  6574. -- should start with `_` to avoid naming collisions with future engine
  6575. -- usage.
  6576. }
  6577. Node definition
  6578. ---------------
  6579. Used by `minetest.register_node`.
  6580. {
  6581. -- <all fields allowed in item definitions>
  6582. drawtype = "normal", -- See "Node drawtypes"
  6583. visual_scale = 1.0,
  6584. -- Supported for drawtypes "plantlike", "signlike", "torchlike",
  6585. -- "firelike", "mesh", "nodebox", "allfaces".
  6586. -- For plantlike and firelike, the image will start at the bottom of the
  6587. -- node. For torchlike, the image will start at the surface to which the
  6588. -- node "attaches". For the other drawtypes the image will be centered
  6589. -- on the node.
  6590. tiles = {tile definition 1, def2, def3, def4, def5, def6},
  6591. -- Textures of node; +Y, -Y, +X, -X, +Z, -Z
  6592. -- List can be shortened to needed length.
  6593. overlay_tiles = {tile definition 1, def2, def3, def4, def5, def6},
  6594. -- Same as `tiles`, but these textures are drawn on top of the base
  6595. -- tiles. You can use this to colorize only specific parts of your
  6596. -- texture. If the texture name is an empty string, that overlay is not
  6597. -- drawn. Since such tiles are drawn twice, it is not recommended to use
  6598. -- overlays on very common nodes.
  6599. special_tiles = {tile definition 1, Tile definition 2},
  6600. -- Special textures of node; used rarely.
  6601. -- List can be shortened to needed length.
  6602. color = ColorSpec,
  6603. -- The node's original color will be multiplied with this color.
  6604. -- If the node has a palette, then this setting only has an effect in
  6605. -- the inventory and on the wield item.
  6606. use_texture_alpha = ...,
  6607. -- Specifies how the texture's alpha channel will be used for rendering.
  6608. -- possible values:
  6609. -- * "opaque": Node is rendered opaque regardless of alpha channel
  6610. -- * "clip": A given pixel is either fully see-through or opaque
  6611. -- depending on the alpha channel being below/above 50% in value
  6612. -- * "blend": The alpha channel specifies how transparent a given pixel
  6613. -- of the rendered node is
  6614. -- The default is "opaque" for drawtypes normal, liquid and flowingliquid;
  6615. -- "clip" otherwise.
  6616. -- If set to a boolean value (deprecated): true either sets it to blend
  6617. -- or clip, false sets it to clip or opaque mode depending on the drawtype.
  6618. palette = "",
  6619. -- The node's `param2` is used to select a pixel from the image.
  6620. -- Pixels are arranged from left to right and from top to bottom.
  6621. -- The node's color will be multiplied with the selected pixel's color.
  6622. -- Tiles can override this behavior.
  6623. -- Only when `paramtype2` supports palettes.
  6624. post_effect_color = "#00000000",
  6625. -- Screen tint if player is inside node, see "ColorSpec"
  6626. paramtype = "none", -- See "Nodes"
  6627. paramtype2 = "none", -- See "Nodes"
  6628. place_param2 = 0,
  6629. -- Value for param2 that is set when player places node
  6630. is_ground_content = true,
  6631. -- If false, the cave generator and dungeon generator will not carve
  6632. -- through this node.
  6633. -- Specifically, this stops mod-added nodes being removed by caves and
  6634. -- dungeons when those generate in a neighbor mapchunk and extend out
  6635. -- beyond the edge of that mapchunk.
  6636. sunlight_propagates = false,
  6637. -- If true, sunlight will go infinitely through this node
  6638. walkable = true, -- If true, objects collide with node
  6639. pointable = true, -- If true, can be pointed at
  6640. diggable = true, -- If false, can never be dug
  6641. climbable = false, -- If true, can be climbed on like a ladder
  6642. move_resistance = 0,
  6643. -- Slows down movement of players through this node (max. 7).
  6644. -- If this is nil, it will be equal to liquid_viscosity.
  6645. -- Note: If liquid movement physics apply to the node
  6646. -- (see `liquid_move_physics`), the movement speed will also be
  6647. -- affected by the `movement_liquid_*` settings.
  6648. buildable_to = false, -- If true, placed nodes can replace this node
  6649. floodable = false,
  6650. -- If true, liquids flow into and replace this node.
  6651. -- Warning: making a liquid node 'floodable' will cause problems.
  6652. liquidtype = "none", -- specifies liquid flowing physics
  6653. -- * "none": no liquid flowing physics
  6654. -- * "source": spawns flowing liquid nodes at all 4 sides and below;
  6655. -- recommended drawtype: "liquid".
  6656. -- * "flowing": spawned from source, spawns more flowing liquid nodes
  6657. -- around it until `liquid_range` is reached;
  6658. -- will drain out without a source;
  6659. -- recommended drawtype: "flowingliquid".
  6660. -- If it's "source" or "flowing" and `liquid_range > 0`, then
  6661. -- both `liquid_alternative_*` fields must be specified
  6662. liquid_alternative_flowing = "",
  6663. -- Node that represents the flowing version of the liquid
  6664. liquid_alternative_source = "",
  6665. -- Node that represents the source version of the liquid
  6666. liquid_viscosity = 0,
  6667. -- Controls speed at which the liquid spreads/flows (max. 7).
  6668. -- 0 is fastest, 7 is slowest.
  6669. -- By default, this also slows down movement of players inside the node
  6670. -- (can be overridden using `move_resistance`)
  6671. liquid_renewable = true,
  6672. -- If true, a new liquid source can be created by placing two or more
  6673. -- sources nearby
  6674. liquid_move_physics = nil, -- specifies movement physics if inside node
  6675. -- * false: No liquid movement physics apply.
  6676. -- * true: Enables liquid movement physics. Enables things like
  6677. -- ability to "swim" up/down, sinking slowly if not moving,
  6678. -- smoother speed change when falling into, etc. The `movement_liquid_*`
  6679. -- settings apply.
  6680. -- * nil: Will be treated as true if `liquidype ~= "none"`
  6681. -- and as false otherwise.
  6682. leveled = 0,
  6683. -- Only valid for "nodebox" drawtype with 'type = "leveled"'.
  6684. -- Allows defining the nodebox height without using param2.
  6685. -- The nodebox height is 'leveled' / 64 nodes.
  6686. -- The maximum value of 'leveled' is `leveled_max`.
  6687. leveled_max = 127,
  6688. -- Maximum value for `leveled` (0-127), enforced in
  6689. -- `minetest.set_node_level` and `minetest.add_node_level`.
  6690. -- Values above 124 might causes collision detection issues.
  6691. liquid_range = 8,
  6692. -- Maximum distance that flowing liquid nodes can spread around
  6693. -- source on flat land;
  6694. -- maximum = 8; set to 0 to disable liquid flow
  6695. drowning = 0,
  6696. -- Player will take this amount of damage if no bubbles are left
  6697. damage_per_second = 0,
  6698. -- If player is inside node, this damage is caused
  6699. node_box = {type = "regular"}, -- See "Node boxes"
  6700. connects_to = {},
  6701. -- Used for nodebox nodes with the type == "connected".
  6702. -- Specifies to what neighboring nodes connections will be drawn.
  6703. -- e.g. `{"group:fence", "default:wood"}` or `"default:stone"`
  6704. connect_sides = {},
  6705. -- Tells connected nodebox nodes to connect only to these sides of this
  6706. -- node. possible: "top", "bottom", "front", "left", "back", "right"
  6707. mesh = "",
  6708. -- File name of mesh when using "mesh" drawtype
  6709. selection_box = {
  6710. -- see [Node boxes] for possibilities
  6711. },
  6712. -- Custom selection box definition. Multiple boxes can be defined.
  6713. -- If "nodebox" drawtype is used and selection_box is nil, then node_box
  6714. -- definition is used for the selection box.
  6715. collision_box = {
  6716. -- see [Node boxes] for possibilities
  6717. },
  6718. -- Custom collision box definition. Multiple boxes can be defined.
  6719. -- If "nodebox" drawtype is used and collision_box is nil, then node_box
  6720. -- definition is used for the collision box.
  6721. -- Support maps made in and before January 2012
  6722. legacy_facedir_simple = false,
  6723. legacy_wallmounted = false,
  6724. waving = 0,
  6725. -- Valid for drawtypes:
  6726. -- mesh, nodebox, plantlike, allfaces_optional, liquid, flowingliquid.
  6727. -- 1 - wave node like plants (node top moves side-to-side, bottom is fixed)
  6728. -- 2 - wave node like leaves (whole node moves side-to-side)
  6729. -- 3 - wave node like liquids (whole node moves up and down)
  6730. -- Not all models will properly wave.
  6731. -- plantlike drawtype can only wave like plants.
  6732. -- allfaces_optional drawtype can only wave like leaves.
  6733. -- liquid, flowingliquid drawtypes can only wave like liquids.
  6734. sounds = {
  6735. -- Definition of node sounds to be played at various events.
  6736. -- All fields in this table are optional.
  6737. footstep = <SimpleSoundSpec>,
  6738. -- If walkable, played when object walks on it. If node is
  6739. -- climbable or a liquid, played when object moves through it
  6740. dig = <SimpleSoundSpec> or "__group",
  6741. -- While digging node.
  6742. -- If `"__group"`, then the sound will be
  6743. -- `default_dig_<groupname>`, where `<groupname>` is the
  6744. -- name of the item's digging group with the fastest digging time.
  6745. -- In case of a tie, one of the sounds will be played (but we
  6746. -- cannot predict which one)
  6747. -- Default value: `"__group"`
  6748. dug = <SimpleSoundSpec>,
  6749. -- Node was dug
  6750. place = <SimpleSoundSpec>,
  6751. -- Node was placed. Also played after falling
  6752. place_failed = <SimpleSoundSpec>,
  6753. -- When node placement failed.
  6754. -- Note: This happens if the _built-in_ node placement failed.
  6755. -- This sound will still be played if the node is placed in the
  6756. -- `on_place` callback manually.
  6757. fall = <SimpleSoundSpec>,
  6758. -- When node starts to fall or is detached
  6759. },
  6760. drop = "",
  6761. -- Name of dropped item when dug.
  6762. -- Default dropped item is the node itself.
  6763. -- Using a table allows multiple items, drop chances and item filtering:
  6764. drop = {
  6765. max_items = 1,
  6766. -- Maximum number of item lists to drop.
  6767. -- The entries in 'items' are processed in order. For each:
  6768. -- Item filtering is applied, chance of drop is applied, if both are
  6769. -- successful the entire item list is dropped.
  6770. -- Entry processing continues until the number of dropped item lists
  6771. -- equals 'max_items'.
  6772. -- Therefore, entries should progress from low to high drop chance.
  6773. items = {
  6774. -- Examples:
  6775. {
  6776. -- 1 in 1000 chance of dropping a diamond.
  6777. -- Default rarity is '1'.
  6778. rarity = 1000,
  6779. items = {"default:diamond"},
  6780. },
  6781. {
  6782. -- Only drop if using an item whose name is identical to one
  6783. -- of these.
  6784. tools = {"default:shovel_mese", "default:shovel_diamond"},
  6785. rarity = 5,
  6786. items = {"default:dirt"},
  6787. -- Whether all items in the dropped item list inherit the
  6788. -- hardware coloring palette color from the dug node.
  6789. -- Default is 'false'.
  6790. inherit_color = true,
  6791. },
  6792. {
  6793. -- Only drop if using an item whose name contains
  6794. -- "default:shovel_" (this item filtering by string matching
  6795. -- is deprecated, use tool_groups instead).
  6796. tools = {"~default:shovel_"},
  6797. rarity = 2,
  6798. -- The item list dropped.
  6799. items = {"default:sand", "default:desert_sand"},
  6800. },
  6801. {
  6802. -- Only drop if using an item in the "magicwand" group, or
  6803. -- an item that is in both the "pickaxe" and the "lucky"
  6804. -- groups.
  6805. tool_groups = {
  6806. "magicwand",
  6807. {"pickaxe", "lucky"}
  6808. },
  6809. items = {"default:coal_lump"},
  6810. },
  6811. },
  6812. },
  6813. on_construct = function(pos),
  6814. -- Node constructor; called after adding node.
  6815. -- Can set up metadata and stuff like that.
  6816. -- Not called for bulk node placement (i.e. schematics and VoxelManip).
  6817. -- default: nil
  6818. on_destruct = function(pos),
  6819. -- Node destructor; called before removing node.
  6820. -- Not called for bulk node placement.
  6821. -- default: nil
  6822. after_destruct = function(pos, oldnode),
  6823. -- Node destructor; called after removing node.
  6824. -- Not called for bulk node placement.
  6825. -- default: nil
  6826. on_flood = function(pos, oldnode, newnode),
  6827. -- Called when a liquid (newnode) is about to flood oldnode, if it has
  6828. -- `floodable = true` in the nodedef. Not called for bulk node placement
  6829. -- (i.e. schematics and VoxelManip) or air nodes. If return true the
  6830. -- node is not flooded, but on_flood callback will most likely be called
  6831. -- over and over again every liquid update interval.
  6832. -- Default: nil
  6833. -- Warning: making a liquid node 'floodable' will cause problems.
  6834. preserve_metadata = function(pos, oldnode, oldmeta, drops),
  6835. -- Called when oldnode is about be converted to an item, but before the
  6836. -- node is deleted from the world or the drops are added. This is
  6837. -- generally the result of either the node being dug or an attached node
  6838. -- becoming detached.
  6839. -- oldmeta are the metadata fields (table) of the node before deletion.
  6840. -- drops is a table of ItemStacks, so any metadata to be preserved can
  6841. -- be added directly to one or more of the dropped items. See
  6842. -- "ItemStackMetaRef".
  6843. -- default: nil
  6844. after_place_node = function(pos, placer, itemstack, pointed_thing),
  6845. -- Called after constructing node when node was placed using
  6846. -- minetest.item_place_node / minetest.place_node.
  6847. -- If return true no item is taken from itemstack.
  6848. -- `placer` may be any valid ObjectRef or nil.
  6849. -- default: nil
  6850. after_dig_node = function(pos, oldnode, oldmetadata, digger),
  6851. -- oldmetadata is in table format.
  6852. -- Called after destructing node when node was dug using
  6853. -- minetest.node_dig / minetest.dig_node.
  6854. -- default: nil
  6855. can_dig = function(pos, [player]),
  6856. -- Returns true if node can be dug, or false if not.
  6857. -- default: nil
  6858. on_punch = function(pos, node, puncher, pointed_thing),
  6859. -- default: minetest.node_punch
  6860. -- Called when puncher (an ObjectRef) punches the node at pos.
  6861. -- By default calls minetest.register_on_punchnode callbacks.
  6862. on_rightclick = function(pos, node, clicker, itemstack, pointed_thing),
  6863. -- default: nil
  6864. -- Called when clicker (an ObjectRef) used the 'place/build' key
  6865. -- (not neccessarily an actual rightclick)
  6866. -- while pointing at the node at pos with 'node' being the node table.
  6867. -- itemstack will hold clicker's wielded item.
  6868. -- Shall return the leftover itemstack.
  6869. -- Note: pointed_thing can be nil, if a mod calls this function.
  6870. -- This function does not get triggered by clients <=0.4.16 if the
  6871. -- "formspec" node metadata field is set.
  6872. on_dig = function(pos, node, digger),
  6873. -- default: minetest.node_dig
  6874. -- By default checks privileges, wears out item (if tool) and removes node.
  6875. -- return true if the node was dug successfully, false otherwise.
  6876. -- Deprecated: returning nil is the same as returning true.
  6877. on_timer = function(pos, elapsed),
  6878. -- default: nil
  6879. -- called by NodeTimers, see minetest.get_node_timer and NodeTimerRef.
  6880. -- elapsed is the total time passed since the timer was started.
  6881. -- return true to run the timer for another cycle with the same timeout
  6882. -- value.
  6883. on_receive_fields = function(pos, formname, fields, sender),
  6884. -- fields = {name1 = value1, name2 = value2, ...}
  6885. -- Called when an UI form (e.g. sign text input) returns data.
  6886. -- See minetest.register_on_player_receive_fields for more info.
  6887. -- default: nil
  6888. allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
  6889. -- Called when a player wants to move items inside the inventory.
  6890. -- Return value: number of items allowed to move.
  6891. allow_metadata_inventory_put = function(pos, listname, index, stack, player),
  6892. -- Called when a player wants to put something into the inventory.
  6893. -- Return value: number of items allowed to put.
  6894. -- Return value -1: Allow and don't modify item count in inventory.
  6895. allow_metadata_inventory_take = function(pos, listname, index, stack, player),
  6896. -- Called when a player wants to take something out of the inventory.
  6897. -- Return value: number of items allowed to take.
  6898. -- Return value -1: Allow and don't modify item count in inventory.
  6899. on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
  6900. on_metadata_inventory_put = function(pos, listname, index, stack, player),
  6901. on_metadata_inventory_take = function(pos, listname, index, stack, player),
  6902. -- Called after the actual action has happened, according to what was
  6903. -- allowed.
  6904. -- No return value.
  6905. on_blast = function(pos, intensity),
  6906. -- intensity: 1.0 = mid range of regular TNT.
  6907. -- If defined, called when an explosion touches the node, instead of
  6908. -- removing the node.
  6909. mod_origin = "modname",
  6910. -- stores which mod actually registered a node
  6911. -- If the source could not be determined it contains "??"
  6912. -- Useful for getting which mod truly registered something
  6913. -- example: if a node is registered as ":othermodname:nodename",
  6914. -- nodename will show "othermodname", but mod_orgin will say "modname"
  6915. }
  6916. Crafting recipes
  6917. ----------------
  6918. Used by `minetest.register_craft`.
  6919. ### Shaped
  6920. {
  6921. output = "default:pick_stone",
  6922. recipe = {
  6923. {"default:cobble", "default:cobble", "default:cobble"},
  6924. {"", "default:stick", ""},
  6925. {"", "default:stick", ""}, -- Also groups; e.g. "group:crumbly"
  6926. },
  6927. replacements = <list of item pairs>,
  6928. -- replacements: replace one input item with another item on crafting
  6929. -- (optional).
  6930. }
  6931. ### Shapeless
  6932. {
  6933. type = "shapeless",
  6934. output = "mushrooms:mushroom_stew",
  6935. recipe = {
  6936. "mushrooms:bowl",
  6937. "mushrooms:mushroom_brown",
  6938. "mushrooms:mushroom_red",
  6939. },
  6940. replacements = <list of item pairs>,
  6941. }
  6942. ### Tool repair
  6943. {
  6944. type = "toolrepair",
  6945. additional_wear = -0.02, -- multiplier of 65536
  6946. }
  6947. Adds a shapeless recipe for *every* tool that doesn't have the `disable_repair=1`
  6948. group. Player can put 2 equal tools in the craft grid to get one "repaired" tool
  6949. back.
  6950. The wear of the output is determined by the wear of both tools, plus a
  6951. 'repair bonus' given by `additional_wear`. To reduce the wear (i.e. 'repair'),
  6952. you want `additional_wear` to be negative.
  6953. The formula used to calculate the resulting wear is:
  6954. 65536 * (1 - ( (1 - tool_1_wear) + (1 - tool_2_wear) + additional_wear ))
  6955. The result is rounded and can't be lower than 0. If the result is 65536 or higher,
  6956. no crafting is possible.
  6957. ### Cooking
  6958. {
  6959. type = "cooking",
  6960. output = "default:glass",
  6961. recipe = "default:sand",
  6962. cooktime = 3,
  6963. }
  6964. ### Furnace fuel
  6965. {
  6966. type = "fuel",
  6967. recipe = "bucket:bucket_lava",
  6968. burntime = 60,
  6969. replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}},
  6970. }
  6971. The engine does not implement anything specific to cooking or fuels, but the
  6972. recpies can be retrieved later using `minetest.get_craft_result` to have a
  6973. consistent interface across different games/mods.
  6974. Ore definition
  6975. --------------
  6976. Used by `minetest.register_ore`.
  6977. See [Ores] section above for essential information.
  6978. {
  6979. ore_type = "",
  6980. -- Supported: "scatter", "sheet", "puff", "blob", "vein", "stratum"
  6981. ore = "",
  6982. -- Ore node to place
  6983. ore_param2 = 0,
  6984. -- Param2 to set for ore (e.g. facedir rotation)
  6985. wherein = "",
  6986. -- Node to place ore in. Multiple are possible by passing a list.
  6987. clust_scarcity = 8 * 8 * 8,
  6988. -- Ore has a 1 out of clust_scarcity chance of spawning in a node.
  6989. -- If the desired average distance between ores is 'd', set this to
  6990. -- d * d * d.
  6991. clust_num_ores = 8,
  6992. -- Number of ores in a cluster
  6993. clust_size = 3,
  6994. -- Size of the bounding box of the cluster.
  6995. -- In this example, there is a 3 * 3 * 3 cluster where 8 out of the 27
  6996. -- nodes are coal ore.
  6997. y_min = -31000,
  6998. y_max = 31000,
  6999. -- Lower and upper limits for ore (inclusive)
  7000. flags = "",
  7001. -- Attributes for the ore generation, see 'Ore attributes' section above
  7002. noise_threshold = 0,
  7003. -- If noise is above this threshold, ore is placed. Not needed for a
  7004. -- uniform distribution.
  7005. noise_params = {
  7006. offset = 0,
  7007. scale = 1,
  7008. spread = {x = 100, y = 100, z = 100},
  7009. seed = 23,
  7010. octaves = 3,
  7011. persistence = 0.7
  7012. },
  7013. -- NoiseParams structure describing one of the perlin noises used for
  7014. -- ore distribution.
  7015. -- Needed by "sheet", "puff", "blob" and "vein" ores.
  7016. -- Omit from "scatter" ore for a uniform ore distribution.
  7017. -- Omit from "stratum" ore for a simple horizontal strata from y_min to
  7018. -- y_max.
  7019. biomes = {"desert", "rainforest"},
  7020. -- List of biomes in which this ore occurs.
  7021. -- Occurs in all biomes if this is omitted, and ignored if the Mapgen
  7022. -- being used does not support biomes.
  7023. -- Can be a list of (or a single) biome names, IDs, or definitions.
  7024. -- Type-specific parameters
  7025. -- "sheet"
  7026. column_height_min = 1,
  7027. column_height_max = 16,
  7028. column_midpoint_factor = 0.5,
  7029. -- "puff"
  7030. np_puff_top = {
  7031. offset = 4,
  7032. scale = 2,
  7033. spread = {x = 100, y = 100, z = 100},
  7034. seed = 47,
  7035. octaves = 3,
  7036. persistence = 0.7
  7037. },
  7038. np_puff_bottom = {
  7039. offset = 4,
  7040. scale = 2,
  7041. spread = {x = 100, y = 100, z = 100},
  7042. seed = 11,
  7043. octaves = 3,
  7044. persistence = 0.7
  7045. },
  7046. -- "vein"
  7047. random_factor = 1.0,
  7048. -- "stratum"
  7049. np_stratum_thickness = {
  7050. offset = 8,
  7051. scale = 4,
  7052. spread = {x = 100, y = 100, z = 100},
  7053. seed = 17,
  7054. octaves = 3,
  7055. persistence = 0.7
  7056. },
  7057. stratum_thickness = 8, -- only used if no noise defined
  7058. }
  7059. Biome definition
  7060. ----------------
  7061. Used by `minetest.register_biome`.
  7062. The maximum number of biomes that can be used is 65535. However, using an
  7063. excessive number of biomes will slow down map generation. Depending on desired
  7064. performance and computing power the practical limit is much lower.
  7065. {
  7066. name = "tundra",
  7067. node_dust = "default:snow",
  7068. -- Node dropped onto upper surface after all else is generated
  7069. node_top = "default:dirt_with_snow",
  7070. depth_top = 1,
  7071. -- Node forming surface layer of biome and thickness of this layer
  7072. node_filler = "default:permafrost",
  7073. depth_filler = 3,
  7074. -- Node forming lower layer of biome and thickness of this layer
  7075. node_stone = "default:bluestone",
  7076. -- Node that replaces all stone nodes between roughly y_min and y_max.
  7077. node_water_top = "default:ice",
  7078. depth_water_top = 10,
  7079. -- Node forming a surface layer in seawater with the defined thickness
  7080. node_water = "",
  7081. -- Node that replaces all seawater nodes not in the surface layer
  7082. node_river_water = "default:ice",
  7083. -- Node that replaces river water in mapgens that use
  7084. -- default:river_water
  7085. node_riverbed = "default:gravel",
  7086. depth_riverbed = 2,
  7087. -- Node placed under river water and thickness of this layer
  7088. node_cave_liquid = "default:lava_source",
  7089. node_cave_liquid = {"default:water_source", "default:lava_source"},
  7090. -- Nodes placed inside 50% of the medium size caves.
  7091. -- Multiple nodes can be specified, each cave will use a randomly
  7092. -- chosen node from the list.
  7093. -- If this field is left out or 'nil', cave liquids fall back to
  7094. -- classic behaviour of lava and water distributed using 3D noise.
  7095. -- For no cave liquid, specify "air".
  7096. node_dungeon = "default:cobble",
  7097. -- Node used for primary dungeon structure.
  7098. -- If absent, dungeon nodes fall back to the 'mapgen_cobble' mapgen
  7099. -- alias, if that is also absent, dungeon nodes fall back to the biome
  7100. -- 'node_stone'.
  7101. -- If present, the following two nodes are also used.
  7102. node_dungeon_alt = "default:mossycobble",
  7103. -- Node used for randomly-distributed alternative structure nodes.
  7104. -- If alternative structure nodes are not wanted leave this absent.
  7105. node_dungeon_stair = "stairs:stair_cobble",
  7106. -- Node used for dungeon stairs.
  7107. -- If absent, stairs fall back to 'node_dungeon'.
  7108. y_max = 31000,
  7109. y_min = 1,
  7110. -- Upper and lower limits for biome.
  7111. -- Alternatively you can use xyz limits as shown below.
  7112. max_pos = {x = 31000, y = 128, z = 31000},
  7113. min_pos = {x = -31000, y = 9, z = -31000},
  7114. -- xyz limits for biome, an alternative to using 'y_min' and 'y_max'.
  7115. -- Biome is limited to a cuboid defined by these positions.
  7116. -- Any x, y or z field left undefined defaults to -31000 in 'min_pos' or
  7117. -- 31000 in 'max_pos'.
  7118. vertical_blend = 8,
  7119. -- Vertical distance in nodes above 'y_max' over which the biome will
  7120. -- blend with the biome above.
  7121. -- Set to 0 for no vertical blend. Defaults to 0.
  7122. heat_point = 0,
  7123. humidity_point = 50,
  7124. -- Characteristic temperature and humidity for the biome.
  7125. -- These values create 'biome points' on a voronoi diagram with heat and
  7126. -- humidity as axes. The resulting voronoi cells determine the
  7127. -- distribution of the biomes.
  7128. -- Heat and humidity have average values of 50, vary mostly between
  7129. -- 0 and 100 but can exceed these values.
  7130. }
  7131. Decoration definition
  7132. ---------------------
  7133. See [Decoration types]. Used by `minetest.register_decoration`.
  7134. {
  7135. deco_type = "simple",
  7136. -- Type. "simple" or "schematic" supported
  7137. place_on = "default:dirt_with_grass",
  7138. -- Node (or list of nodes) that the decoration can be placed on
  7139. sidelen = 8,
  7140. -- Size of the square (X / Z) divisions of the mapchunk being generated.
  7141. -- Determines the resolution of noise variation if used.
  7142. -- If the chunk size is not evenly divisible by sidelen, sidelen is made
  7143. -- equal to the chunk size.
  7144. fill_ratio = 0.02,
  7145. -- The value determines 'decorations per surface node'.
  7146. -- Used only if noise_params is not specified.
  7147. -- If >= 10.0 complete coverage is enabled and decoration placement uses
  7148. -- a different and much faster method.
  7149. noise_params = {
  7150. offset = 0,
  7151. scale = 0.45,
  7152. spread = {x = 100, y = 100, z = 100},
  7153. seed = 354,
  7154. octaves = 3,
  7155. persistence = 0.7,
  7156. lacunarity = 2.0,
  7157. flags = "absvalue"
  7158. },
  7159. -- NoiseParams structure describing the perlin noise used for decoration
  7160. -- distribution.
  7161. -- A noise value is calculated for each square division and determines
  7162. -- 'decorations per surface node' within each division.
  7163. -- If the noise value >= 10.0 complete coverage is enabled and
  7164. -- decoration placement uses a different and much faster method.
  7165. biomes = {"Oceanside", "Hills", "Plains"},
  7166. -- List of biomes in which this decoration occurs. Occurs in all biomes
  7167. -- if this is omitted, and ignored if the Mapgen being used does not
  7168. -- support biomes.
  7169. -- Can be a list of (or a single) biome names, IDs, or definitions.
  7170. y_min = -31000,
  7171. y_max = 31000,
  7172. -- Lower and upper limits for decoration (inclusive).
  7173. -- These parameters refer to the Y co-ordinate of the 'place_on' node.
  7174. spawn_by = "default:water",
  7175. -- Node (or list of nodes) that the decoration only spawns next to.
  7176. -- Checks the 8 neighbouring nodes on the same Y, and also the ones
  7177. -- at Y+1, excluding both center nodes.
  7178. num_spawn_by = 1,
  7179. -- Number of spawn_by nodes that must be surrounding the decoration
  7180. -- position to occur.
  7181. -- If absent or -1, decorations occur next to any nodes.
  7182. flags = "liquid_surface, force_placement, all_floors, all_ceilings",
  7183. -- Flags for all decoration types.
  7184. -- "liquid_surface": Instead of placement on the highest solid surface
  7185. -- in a mapchunk column, placement is on the highest liquid surface.
  7186. -- Placement is disabled if solid nodes are found above the liquid
  7187. -- surface.
  7188. -- "force_placement": Nodes other than "air" and "ignore" are replaced
  7189. -- by the decoration.
  7190. -- "all_floors", "all_ceilings": Instead of placement on the highest
  7191. -- surface in a mapchunk the decoration is placed on all floor and/or
  7192. -- ceiling surfaces, for example in caves and dungeons.
  7193. -- Ceiling decorations act as an inversion of floor decorations so the
  7194. -- effect of 'place_offset_y' is inverted.
  7195. -- Y-slice probabilities do not function correctly for ceiling
  7196. -- schematic decorations as the behaviour is unchanged.
  7197. -- If a single decoration registration has both flags the floor and
  7198. -- ceiling decorations will be aligned vertically.
  7199. ----- Simple-type parameters
  7200. decoration = "default:grass",
  7201. -- The node name used as the decoration.
  7202. -- If instead a list of strings, a randomly selected node from the list
  7203. -- is placed as the decoration.
  7204. height = 1,
  7205. -- Decoration height in nodes.
  7206. -- If height_max is not 0, this is the lower limit of a randomly
  7207. -- selected height.
  7208. height_max = 0,
  7209. -- Upper limit of the randomly selected height.
  7210. -- If absent, the parameter 'height' is used as a constant.
  7211. param2 = 0,
  7212. -- Param2 value of decoration nodes.
  7213. -- If param2_max is not 0, this is the lower limit of a randomly
  7214. -- selected param2.
  7215. param2_max = 0,
  7216. -- Upper limit of the randomly selected param2.
  7217. -- If absent, the parameter 'param2' is used as a constant.
  7218. place_offset_y = 0,
  7219. -- Y offset of the decoration base node relative to the standard base
  7220. -- node position.
  7221. -- Can be positive or negative. Default is 0.
  7222. -- Effect is inverted for "all_ceilings" decorations.
  7223. -- Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
  7224. -- to the 'place_on' node.
  7225. ----- Schematic-type parameters
  7226. schematic = "foobar.mts",
  7227. -- If schematic is a string, it is the filepath relative to the current
  7228. -- working directory of the specified Minetest schematic file.
  7229. -- Could also be the ID of a previously registered schematic.
  7230. schematic = {
  7231. size = {x = 4, y = 6, z = 4},
  7232. data = {
  7233. {name = "default:cobble", param1 = 255, param2 = 0},
  7234. {name = "default:dirt_with_grass", param1 = 255, param2 = 0},
  7235. {name = "air", param1 = 255, param2 = 0},
  7236. ...
  7237. },
  7238. yslice_prob = {
  7239. {ypos = 2, prob = 128},
  7240. {ypos = 5, prob = 64},
  7241. ...
  7242. },
  7243. },
  7244. -- Alternative schematic specification by supplying a table. The fields
  7245. -- size and data are mandatory whereas yslice_prob is optional.
  7246. -- See 'Schematic specifier' for details.
  7247. replacements = {["oldname"] = "convert_to", ...},
  7248. -- Map of node names to replace in the schematic after reading it.
  7249. flags = "place_center_x, place_center_y, place_center_z",
  7250. -- Flags for schematic decorations. See 'Schematic attributes'.
  7251. rotation = "90",
  7252. -- Rotation can be "0", "90", "180", "270", or "random"
  7253. place_offset_y = 0,
  7254. -- If the flag 'place_center_y' is set this parameter is ignored.
  7255. -- Y offset of the schematic base node layer relative to the 'place_on'
  7256. -- node.
  7257. -- Can be positive or negative. Default is 0.
  7258. -- Effect is inverted for "all_ceilings" decorations.
  7259. -- Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
  7260. -- to the 'place_on' node.
  7261. }
  7262. Chat command definition
  7263. -----------------------
  7264. Used by `minetest.register_chatcommand`.
  7265. {
  7266. params = "<name> <privilege>", -- Short parameter description
  7267. description = "Remove privilege from player", -- Full description
  7268. privs = {privs=true}, -- Require the "privs" privilege to run
  7269. func = function(name, param),
  7270. -- Called when command is run. Returns boolean success and text output.
  7271. -- Special case: The help message is shown to the player if `func`
  7272. -- returns false without a text output.
  7273. }
  7274. Note that in params, use of symbols is as follows:
  7275. * `<>` signifies a placeholder to be replaced when the command is used. For
  7276. example, when a player name is needed: `<name>`
  7277. * `[]` signifies param is optional and not required when the command is used.
  7278. For example, if you require param1 but param2 is optional:
  7279. `<param1> [<param2>]`
  7280. * `|` signifies exclusive or. The command requires one param from the options
  7281. provided. For example: `<param1> | <param2>`
  7282. * `()` signifies grouping. For example, when param1 and param2 are both
  7283. required, or only param3 is required: `(<param1> <param2>) | <param3>`
  7284. Privilege definition
  7285. --------------------
  7286. Used by `minetest.register_privilege`.
  7287. {
  7288. description = "",
  7289. -- Privilege description
  7290. give_to_singleplayer = true,
  7291. -- Whether to grant the privilege to singleplayer.
  7292. give_to_admin = true,
  7293. -- Whether to grant the privilege to the server admin.
  7294. -- Uses value of 'give_to_singleplayer' by default.
  7295. on_grant = function(name, granter_name),
  7296. -- Called when given to player 'name' by 'granter_name'.
  7297. -- 'granter_name' will be nil if the priv was granted by a mod.
  7298. on_revoke = function(name, revoker_name),
  7299. -- Called when taken from player 'name' by 'revoker_name'.
  7300. -- 'revoker_name' will be nil if the priv was revoked by a mod.
  7301. -- Note that the above two callbacks will be called twice if a player is
  7302. -- responsible, once with the player name, and then with a nil player
  7303. -- name.
  7304. -- Return true in the above callbacks to stop register_on_priv_grant or
  7305. -- revoke being called.
  7306. }
  7307. Detached inventory callbacks
  7308. ----------------------------
  7309. Used by `minetest.create_detached_inventory`.
  7310. {
  7311. allow_move = function(inv, from_list, from_index, to_list, to_index, count, player),
  7312. -- Called when a player wants to move items inside the inventory.
  7313. -- Return value: number of items allowed to move.
  7314. allow_put = function(inv, listname, index, stack, player),
  7315. -- Called when a player wants to put something into the inventory.
  7316. -- Return value: number of items allowed to put.
  7317. -- Return value -1: Allow and don't modify item count in inventory.
  7318. allow_take = function(inv, listname, index, stack, player),
  7319. -- Called when a player wants to take something out of the inventory.
  7320. -- Return value: number of items allowed to take.
  7321. -- Return value -1: Allow and don't modify item count in inventory.
  7322. on_move = function(inv, from_list, from_index, to_list, to_index, count, player),
  7323. on_put = function(inv, listname, index, stack, player),
  7324. on_take = function(inv, listname, index, stack, player),
  7325. -- Called after the actual action has happened, according to what was
  7326. -- allowed.
  7327. -- No return value.
  7328. }
  7329. HUD Definition
  7330. --------------
  7331. Since most values have multiple different functions, please see the
  7332. documentation in [HUD] section.
  7333. Used by `ObjectRef:hud_add`. Returned by `ObjectRef:hud_get`.
  7334. {
  7335. hud_elem_type = "image",
  7336. -- Type of element, can be "image", "text", "statbar", "inventory",
  7337. -- "waypoint", "image_waypoint", "compass" or "minimap"
  7338. position = {x=0.5, y=0.5},
  7339. -- Top left corner position of element
  7340. name = "<name>",
  7341. scale = {x = 1, y = 1},
  7342. text = "<text>",
  7343. text2 = "<text>",
  7344. number = 0,
  7345. item = 0,
  7346. direction = 0,
  7347. -- Direction: 0: left-right, 1: right-left, 2: top-bottom, 3: bottom-top
  7348. alignment = {x=0, y=0},
  7349. offset = {x=0, y=0},
  7350. world_pos = {x=0, y=0, z=0},
  7351. size = {x=0, y=0},
  7352. z_index = 0,
  7353. -- Z index: lower z-index HUDs are displayed behind higher z-index HUDs
  7354. style = 0,
  7355. }
  7356. Particle definition
  7357. -------------------
  7358. Used by `minetest.add_particle`.
  7359. {
  7360. pos = {x=0, y=0, z=0},
  7361. velocity = {x=0, y=0, z=0},
  7362. acceleration = {x=0, y=0, z=0},
  7363. -- Spawn particle at pos with velocity and acceleration
  7364. expirationtime = 1,
  7365. -- Disappears after expirationtime seconds
  7366. size = 1,
  7367. -- Scales the visual size of the particle texture.
  7368. -- If `node` is set, size can be set to 0 to spawn a randomly-sized
  7369. -- particle (just like actual node dig particles).
  7370. collisiondetection = false,
  7371. -- If true collides with `walkable` nodes and, depending on the
  7372. -- `object_collision` field, objects too.
  7373. collision_removal = false,
  7374. -- If true particle is removed when it collides.
  7375. -- Requires collisiondetection = true to have any effect.
  7376. object_collision = false,
  7377. -- If true particle collides with objects that are defined as
  7378. -- `physical = true,` and `collide_with_objects = true,`.
  7379. -- Requires collisiondetection = true to have any effect.
  7380. vertical = false,
  7381. -- If true faces player using y axis only
  7382. texture = "image.png",
  7383. -- The texture of the particle
  7384. -- v5.6.0 and later: also supports the table format described in the
  7385. -- following section
  7386. playername = "singleplayer",
  7387. -- Optional, if specified spawns particle only on the player's client
  7388. animation = {Tile Animation definition},
  7389. -- Optional, specifies how to animate the particle texture
  7390. glow = 0
  7391. -- Optional, specify particle self-luminescence in darkness.
  7392. -- Values 0-14.
  7393. node = {name = "ignore", param2 = 0},
  7394. -- Optional, if specified the particle will have the same appearance as
  7395. -- node dig particles for the given node.
  7396. -- `texture` and `animation` will be ignored if this is set.
  7397. node_tile = 0,
  7398. -- Optional, only valid in combination with `node`
  7399. -- If set to a valid number 1-6, specifies the tile from which the
  7400. -- particle texture is picked.
  7401. -- Otherwise, the default behavior is used. (currently: any random tile)
  7402. drag = {x=0, y=0, z=0},
  7403. -- v5.6.0 and later: Optional drag value, consult the following section
  7404. bounce = {min = ..., max = ..., bias = 0},
  7405. -- v5.6.0 and later: Optional bounce range, consult the following section
  7406. }
  7407. `ParticleSpawner` definition
  7408. ----------------------------
  7409. Used by `minetest.add_particlespawner`.
  7410. Before v5.6.0, particlespawners used a different syntax and had a more limited set
  7411. of features. Definition fields that are the same in both legacy and modern versions
  7412. are shown in the next listing, and the fields that are used by legacy versions are
  7413. shown separated by a comment; the modern fields are too complex to compactly
  7414. describe in this manner and are documented after the listing.
  7415. The older syntax can be used in combination with the newer syntax (e.g. having
  7416. `minpos`, `maxpos`, and `pos` all set) to support older servers. On newer servers,
  7417. the new syntax will override the older syntax; on older servers, the newer syntax
  7418. will be ignored.
  7419. {
  7420. -- Common fields (same name and meaning in both new and legacy syntax)
  7421. amount = 1,
  7422. -- Number of particles spawned over the time period `time`.
  7423. time = 1,
  7424. -- Lifespan of spawner in seconds.
  7425. -- If time is 0 spawner has infinite lifespan and spawns the `amount` on
  7426. -- a per-second basis.
  7427. collisiondetection = false,
  7428. -- If true collide with `walkable` nodes and, depending on the
  7429. -- `object_collision` field, objects too.
  7430. collision_removal = false,
  7431. -- If true particles are removed when they collide.
  7432. -- Requires collisiondetection = true to have any effect.
  7433. object_collision = false,
  7434. -- If true particles collide with objects that are defined as
  7435. -- `physical = true,` and `collide_with_objects = true,`.
  7436. -- Requires collisiondetection = true to have any effect.
  7437. attached = ObjectRef,
  7438. -- If defined, particle positions, velocities and accelerations are
  7439. -- relative to this object's position and yaw
  7440. vertical = false,
  7441. -- If true face player using y axis only
  7442. texture = "image.png",
  7443. -- The texture of the particle
  7444. playername = "singleplayer",
  7445. -- Optional, if specified spawns particles only on the player's client
  7446. animation = {Tile Animation definition},
  7447. -- Optional, specifies how to animate the particles' texture
  7448. -- v5.6.0 and later: set length to -1 to sychronize the length
  7449. -- of the animation with the expiration time of individual particles.
  7450. -- (-2 causes the animation to be played twice, and so on)
  7451. glow = 0,
  7452. -- Optional, specify particle self-luminescence in darkness.
  7453. -- Values 0-14.
  7454. node = {name = "ignore", param2 = 0},
  7455. -- Optional, if specified the particles will have the same appearance as
  7456. -- node dig particles for the given node.
  7457. -- `texture` and `animation` will be ignored if this is set.
  7458. node_tile = 0,
  7459. -- Optional, only valid in combination with `node`
  7460. -- If set to a valid number 1-6, specifies the tile from which the
  7461. -- particle texture is picked.
  7462. -- Otherwise, the default behavior is used. (currently: any random tile)
  7463. -- Legacy definition fields
  7464. minpos = {x=0, y=0, z=0},
  7465. maxpos = {x=0, y=0, z=0},
  7466. minvel = {x=0, y=0, z=0},
  7467. maxvel = {x=0, y=0, z=0},
  7468. minacc = {x=0, y=0, z=0},
  7469. maxacc = {x=0, y=0, z=0},
  7470. minexptime = 1,
  7471. maxexptime = 1,
  7472. minsize = 1,
  7473. maxsize = 1,
  7474. -- The particles' properties are random values between the min and max
  7475. -- values.
  7476. -- applies to: pos, velocity, acceleration, expirationtime, size
  7477. -- If `node` is set, min and maxsize can be set to 0 to spawn
  7478. -- randomly-sized particles (just like actual node dig particles).
  7479. }
  7480. ### Modern definition fields
  7481. After v5.6.0, spawner properties can be defined in several different ways depending
  7482. on the level of control you need. `pos` for instance can be set as a single vector,
  7483. in which case all particles will appear at that exact point throughout the lifetime
  7484. of the spawner. Alternately, it can be specified as a min-max pair, specifying a
  7485. cubic range the particles can appear randomly within. Finally, some properties can
  7486. be animated by suffixing their key with `_tween` (e.g. `pos_tween`) and supplying
  7487. a tween table.
  7488. The following definitions are all equivalent, listed in order of precedence from
  7489. lowest (the legacy syntax) to highest (tween tables). If multiple forms of a
  7490. property definition are present, the highest-precidence form will be selected
  7491. and all lower-precedence fields will be ignored, allowing for graceful
  7492. degradation in older clients).
  7493. {
  7494. -- old syntax
  7495. maxpos = {x = 0, y = 0, z = 0},
  7496. minpos = {x = 0, y = 0, z = 0},
  7497. -- absolute value
  7498. pos = 0,
  7499. -- all components of every particle's position vector will be set to this
  7500. -- value
  7501. -- vec3
  7502. pos = vector.new(0,0,0),
  7503. -- all particles will appear at this exact position throughout the lifetime
  7504. -- of the particlespawner
  7505. -- vec3 range
  7506. pos = {
  7507. -- the particle will appear at a position that is picked at random from
  7508. -- within a cubic range
  7509. min = vector.new(0,0,0),
  7510. -- `min` is the minimum value this property will be set to in particles
  7511. -- spawned by the generator
  7512. max = vector.new(0,0,0),
  7513. -- `max` is the minimum value this property will be set to in particles
  7514. -- spawned by the generator
  7515. bias = 0,
  7516. -- when `bias` is 0, all random values are exactly as likely as any
  7517. -- other. when it is positive, the higher it is, the more likely values
  7518. -- will appear towards the minimum end of the allowed spectrum. when
  7519. -- it is negative, the lower it is, the more likely values will appear
  7520. -- towards the maximum end of the allowed spectrum. the curve is
  7521. -- exponential and there is no particular maximum or minimum value
  7522. },
  7523. -- tween table
  7524. pos_tween = {...},
  7525. -- a tween table should consist of a list of frames in the same form as the
  7526. -- untweened pos property above, which the engine will interpolate between,
  7527. -- and optionally a number of properties that control how the interpolation
  7528. -- takes place. currently **only two frames**, the first and the last, are
  7529. -- used, but extra frames are accepted for the sake of forward compatibility.
  7530. -- any of the above definition styles can be used here as well in any combination
  7531. -- supported by the property type
  7532. pos_tween = {
  7533. style = "fwd",
  7534. -- linear animation from first to last frame (default)
  7535. style = "rev",
  7536. -- linear animation from last to first frame
  7537. style = "pulse",
  7538. -- linear animation from first to last then back to first again
  7539. style = "flicker",
  7540. -- like "pulse", but slightly randomized to add a bit of stutter
  7541. reps = 1,
  7542. -- number of times the animation is played over the particle's lifespan
  7543. start = 0.0,
  7544. -- point in the spawner's lifespan at which the animation begins. 0 is
  7545. -- the very beginning, 1 is the very end
  7546. -- frames can be defined in a number of different ways, depending on the
  7547. -- underlying type of the property. for now, all but the first and last
  7548. -- frame are ignored
  7549. -- frames
  7550. -- floats
  7551. 0, 0,
  7552. -- vec3s
  7553. vector.new(0,0,0),
  7554. vector.new(0,0,0),
  7555. -- vec3 ranges
  7556. { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
  7557. { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
  7558. -- mixed
  7559. 0, { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
  7560. },
  7561. }
  7562. All of the properties that can be defined in this way are listed in the next
  7563. section, along with the datatypes they accept.
  7564. #### List of particlespawner properties
  7565. All of the properties in this list can be animated with `*_tween` tables
  7566. unless otherwise specified. For example, `jitter` can be tweened by setting
  7567. a `jitter_tween` table instead of (or in addition to) a `jitter` table/value.
  7568. Types used are defined in the previous section.
  7569. * vec3 range `pos`: the position at which particles can appear
  7570. * vec3 range `vel`: the initial velocity of the particle
  7571. * vec3 range `acc`: the direction and speed with which the particle
  7572. accelerates
  7573. * vec3 range `jitter`: offsets the velocity of each particle by a random
  7574. amount within the specified range each frame. used to create Brownian motion.
  7575. * vec3 range `drag`: the amount by which absolute particle velocity along
  7576. each axis is decreased per second. a value of 1.0 means that the particle
  7577. will be slowed to a stop over the space of a second; a value of -1.0 means
  7578. that the particle speed will be doubled every second. to avoid interfering
  7579. with gravity provided by `acc`, a drag vector like `vector.new(1,0,1)` can
  7580. be used instead of a uniform value.
  7581. * float range `bounce`: how bouncy the particles are when `collisiondetection`
  7582. is turned on. values less than or equal to `0` turn off particle bounce;
  7583. `1` makes the particles bounce without losing any velocity, and `2` makes
  7584. them double their velocity with every bounce. `bounce` is not bounded but
  7585. values much larger than `1.0` probably aren't very useful.
  7586. * float range `exptime`: the number of seconds after which the particle
  7587. disappears.
  7588. * table `attract`: sets the birth orientation of particles relative to various
  7589. shapes defined in world coordinate space. this is an alternative means of
  7590. setting the velocity which allows particles to emerge from or enter into
  7591. some entity or node on the map, rather than simply being assigned random
  7592. velocity values within a range. the velocity calculated by this method will
  7593. be **added** to that specified by `vel` if `vel` is also set, so in most
  7594. cases **`vel` should be set to 0**. `attract` has the fields:
  7595. * string `kind`: selects the kind of shape towards which the particles will
  7596. be oriented. it must have one of the following values:
  7597. * `"none"`: no attractor is set and the `attractor` table is ignored
  7598. * `"point"`: the particles are attracted to a specific point in space.
  7599. use this also if you want a sphere-like effect, in combination with
  7600. the `radius` property.
  7601. * `"line"`: the particles are attracted to an (infinite) line passing
  7602. through the points `origin` and `angle`. use this for e.g. beacon
  7603. effects, energy beam effects, etc.
  7604. * `"plane"`: the particles are attracted to an (infinite) plane on whose
  7605. surface `origin` designates a point in world coordinate space. use this
  7606. for e.g. particles entering or emerging from a portal.
  7607. * float range `strength`: the speed with which particles will move towards
  7608. `attractor`. If negative, the particles will instead move away from that
  7609. point.
  7610. * vec3 `origin`: the origin point of the shape towards which particles will
  7611. initially be oriented. functions as an offset if `origin_attached` is also
  7612. set.
  7613. * vec3 `direction`: sets the direction in which the attractor shape faces. for
  7614. lines, this sets the angle of the line; e.g. a vector of (0,1,0) will
  7615. create a vertical line that passes through `origin`. for planes, `direction`
  7616. is the surface normal of an infinite plane on whose surface `origin` is
  7617. a point. functions as an offset if `direction_attached` is also set.
  7618. * entity `origin_attached`: allows the origin to be specified as an offset
  7619. from the position of an entity rather than a coordinate in world space.
  7620. * entity `direction_attached`: allows the direction to be specified as an offset
  7621. from the position of an entity rather than a coordinate in world space.
  7622. * bool `die_on_contact`: if true, the particles' lifetimes are adjusted so
  7623. that they will die as they cross the attractor threshold. this behavior
  7624. is the default but is undesirable for some kinds of animations; set it to
  7625. false to allow particles to live out their natural lives.
  7626. * vec3 range `radius`: if set, particles will be arranged in a sphere around
  7627. `pos`. A constant can be used to create a spherical shell of particles, a
  7628. vector to create an ovoid shell, and a range to create a volume; e.g.
  7629. `{min = 0.5, max = 1, bias = 1}` will allow particles to appear between 0.5
  7630. and 1 nodes away from `pos` but will cluster them towards the center of the
  7631. sphere. Usually if `radius` is used, `pos` should be a single point, but it
  7632. can still be a range if you really know what you're doing (e.g. to create a
  7633. "roundcube" emitter volume).
  7634. ### Textures
  7635. In versions before v5.6.0, particlespawner textures could only be specified as a single
  7636. texture string. After v5.6.0, textures can now be specified as a table as well. This
  7637. table contains options that allow simple animations to be applied to the texture.
  7638. texture = {
  7639. name = "mymod_particle_texture.png",
  7640. -- the texture specification string
  7641. alpha = 1.0,
  7642. -- controls how visible the particle is; at 1.0 the particle is fully
  7643. -- visible, at 0, it is completely invisible.
  7644. alpha_tween = {1, 0},
  7645. -- can be used instead of `alpha` to animate the alpha value over the
  7646. -- particle's lifetime. these tween tables work identically to the tween
  7647. -- tables used in particlespawner properties, except that time references
  7648. -- are understood with respect to the particle's lifetime, not the
  7649. -- spawner's. {1,0} fades the particle out over its lifetime.
  7650. scale = 1,
  7651. scale = {x = 1, y = 1},
  7652. -- scales the texture onscreen
  7653. scale_tween = {
  7654. {x = 1, y = 1},
  7655. {x = 0, y = 1},
  7656. },
  7657. -- animates the scale over the particle's lifetime. works like the
  7658. -- alpha_tween table, but can accept two-dimensional vectors as well as
  7659. -- integer values. the example value would cause the particle to shrink
  7660. -- in one dimension over the course of its life until it disappears
  7661. blend = "alpha",
  7662. -- (default) blends transparent pixels with those they are drawn atop
  7663. -- according to the alpha channel of the source texture. useful for
  7664. -- e.g. material objects like rocks, dirt, smoke, or node chunks
  7665. blend = "add",
  7666. -- adds the value of pixels to those underneath them, modulo the sources
  7667. -- alpha channel. useful for e.g. bright light effects like sparks or fire
  7668. blend = "screen",
  7669. -- like "add" but less bright. useful for subtler light effecs. note that
  7670. -- this is NOT formally equivalent to the "screen" effect used in image
  7671. -- editors and compositors, as it does not respect the alpha channel of
  7672. -- of the image being blended
  7673. blend = "sub",
  7674. -- the inverse of "add"; the value of the source pixel is subtracted from
  7675. -- the pixel underneath it. a white pixel will turn whatever is underneath
  7676. -- it black; a black pixel will be "transparent". useful for creating
  7677. -- darkening effects
  7678. animation = {Tile Animation definition},
  7679. -- overrides the particlespawner's global animation property for a single
  7680. -- specific texture
  7681. }
  7682. Instead of setting a single texture definition, it is also possible to set a
  7683. `texpool` property. A `texpool` consists of a list of possible particle textures.
  7684. Every time a particle is spawned, the engine will pick a texture at random from
  7685. the `texpool` and assign it as that particle's texture. You can also specify a
  7686. `texture` in addition to a `texpool`; the `texture` value will be ignored on newer
  7687. clients but will be sent to older (pre-v5.6.0) clients that do not implement
  7688. texpools.
  7689. texpool = {
  7690. "mymod_particle_texture.png";
  7691. { name = "mymod_spark.png", fade = "out" },
  7692. {
  7693. name = "mymod_dust.png",
  7694. alpha = 0.3,
  7695. scale = 1.5,
  7696. animation = {
  7697. type = "vertical_frames",
  7698. aspect_w = 16, aspect_h = 16,
  7699. length = 3,
  7700. -- the animation lasts for 3s and then repeats
  7701. length = -3,
  7702. -- repeat the animation three times over the particle's lifetime
  7703. -- (post-v5.6.0 clients only)
  7704. },
  7705. },
  7706. }
  7707. #### List of animatable texture properties
  7708. While animated particlespawner values vary over the course of the particlespawner's
  7709. lifetime, animated texture properties vary over the lifespans of the individual
  7710. particles spawned with that texture. So a particle with the texture property
  7711. alpha_tween = {
  7712. 0.0, 1.0,
  7713. style = "pulse",
  7714. reps = 4,
  7715. }
  7716. would be invisible at its spawning, pulse visible four times throughout its
  7717. lifespan, and then vanish again before expiring.
  7718. * float `alpha` (0.0 - 1.0): controls the visibility of the texture
  7719. * vec2 `scale`: controls the size of the displayed billboard onscreen. Its units
  7720. are multiples of the parent particle's assigned size (see the `size` property above)
  7721. `HTTPRequest` definition
  7722. ------------------------
  7723. Used by `HTTPApiTable.fetch` and `HTTPApiTable.fetch_async`.
  7724. {
  7725. url = "http://example.org",
  7726. timeout = 10,
  7727. -- Timeout for request to be completed in seconds. Default depends on engine settings.
  7728. method = "GET", "POST", "PUT" or "DELETE"
  7729. -- The http method to use. Defaults to "GET".
  7730. data = "Raw request data string" OR {field1 = "data1", field2 = "data2"},
  7731. -- Data for the POST, PUT or DELETE request.
  7732. -- Accepts both a string and a table. If a table is specified, encodes
  7733. -- table as x-www-form-urlencoded key-value pairs.
  7734. user_agent = "ExampleUserAgent",
  7735. -- Optional, if specified replaces the default minetest user agent with
  7736. -- given string
  7737. extra_headers = { "Accept-Language: en-us", "Accept-Charset: utf-8" },
  7738. -- Optional, if specified adds additional headers to the HTTP request.
  7739. -- You must make sure that the header strings follow HTTP specification
  7740. -- ("Key: Value").
  7741. multipart = boolean
  7742. -- Optional, if true performs a multipart HTTP request.
  7743. -- Default is false.
  7744. -- Post only, data must be array
  7745. post_data = "Raw POST request data string" OR {field1 = "data1", field2 = "data2"},
  7746. -- Deprecated, use `data` instead. Forces `method = "POST"`.
  7747. }
  7748. `HTTPRequestResult` definition
  7749. ------------------------------
  7750. Passed to `HTTPApiTable.fetch` callback. Returned by
  7751. `HTTPApiTable.fetch_async_get`.
  7752. {
  7753. completed = true,
  7754. -- If true, the request has finished (either succeeded, failed or timed
  7755. -- out)
  7756. succeeded = true,
  7757. -- If true, the request was successful
  7758. timeout = false,
  7759. -- If true, the request timed out
  7760. code = 200,
  7761. -- HTTP status code
  7762. data = "response"
  7763. }
  7764. Authentication handler definition
  7765. ---------------------------------
  7766. Used by `minetest.register_authentication_handler`.
  7767. {
  7768. get_auth = function(name),
  7769. -- Get authentication data for existing player `name` (`nil` if player
  7770. -- doesn't exist).
  7771. -- Returns following structure:
  7772. -- `{password=<string>, privileges=<table>, last_login=<number or nil>}`
  7773. create_auth = function(name, password),
  7774. -- Create new auth data for player `name`.
  7775. -- Note that `password` is not plain-text but an arbitrary
  7776. -- representation decided by the engine.
  7777. delete_auth = function(name),
  7778. -- Delete auth data of player `name`.
  7779. -- Returns boolean indicating success (false if player is nonexistent).
  7780. set_password = function(name, password),
  7781. -- Set password of player `name` to `password`.
  7782. -- Auth data should be created if not present.
  7783. set_privileges = function(name, privileges),
  7784. -- Set privileges of player `name`.
  7785. -- `privileges` is in table form, auth data should be created if not
  7786. -- present.
  7787. reload = function(),
  7788. -- Reload authentication data from the storage location.
  7789. -- Returns boolean indicating success.
  7790. record_login = function(name),
  7791. -- Called when player joins, used for keeping track of last_login
  7792. iterate = function(),
  7793. -- Returns an iterator (use with `for` loops) for all player names
  7794. -- currently in the auth database
  7795. }
  7796. Bit Library
  7797. -----------
  7798. 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
  7799. See http://bitop.luajit.org/ for advanced information.