lua_api.txt 353 KB

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