lua_api.txt 307 KB

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