lua_api.txt 339 KB

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