Usebenzisa ulimi lohlelo lwe-Lua, ungakha imidlalo ehlukahlukene, izinsiza,
amarobhothi okuhweba nokunye ukuthuthukiswa. Ulimi lwesiLua kulula ukuluqonda, lunotolika odumile. Kuhlongozwa ukujwayelana nesiLua eduze, futhi ufunde ukubhala irobhothi lokuhweba noma iskripthi ngalolu limi.
- Luyini ulimi lwesiLua futhi luwusizo kanjani?
- Idatha yomlando emfushane
- Izici zolimi lohlelo lwe-Lua
- Izinzuzo nemibi
- Ukuqhathanisa neJavascript
- Izici zamarobhothi ezinhlelo zokuhweba ngolimi lwesiLua
- Uhlolojikelele lwamarobhothi okuhweba angcono kakhulu ku-Lua – izixazululo ezenziwe ngomumo zabaqalayo
- I-Robot-terminal “Delta Pro”
- I-RQ: Iphesenti elilodwa
- RQ: UMartin
- Izinhlobo zemibhalo ye-Lua yetheminali ye-QUIK
- Ungabhala kanjani irobhothi ngesiLua
- Ungahlela kanjani ku-LUA ku-terminal ye-QUIK
- Ungasifaka kanjani isikripthi se-LUA endaweni yokuhweba
Luyini ulimi lwesiLua futhi luwusizo kanjani?
IsiLua siwulimi olushumekayo olusebenziseka kalula. Abaqalayo bayavuma ukuthi ngosizo lwayo, ungafunda izisekelo zokuhlela ngesikhathi esifushane. IsiLua sihlanganiswe ngempumelelo nentuthuko eyahlanganiswa ngolunye ulimi. Kuvame ukutuswa kubafundi abasanda kuqala kwisayensi ye-electronic design.
Ulimi lwesiLua luvame ukusetshenziswa emikhakheni ehlukahlukene. Kungase kube usizo:
- Umsebenzisi odlala imidlalo yekhompiyutha (bhala ama-plugin).
- Uchwepheshe wokuthuthukisa umdlalo (thuthukisa injini).
- Umhleli wokuthuthukisa uhlelo (bhala ama-plugin ezinsiza ezihlukahlukene).
- Unjiniyela ekuqondeni kokushumekiwe (ulimi aluyibambezeli inqubo futhi ikuvumela ukuthi usebenze kahle)
- Abahwebi bokubhala izikripthi kanye nokuhweba ama-bots. [i-id yamagama-ncazo = “okunamathiselwe_13245″ align=”aligncenter” wide=”805″] Irobhothi lokuhweba le-QUIK ku-Lua ngamaleveli okuthenga kabusha[/caption]
Ngenxa ye-Lua, sekudalwe amarobhothi angaphezu kwelilodwa okuhweba. Inzuzo ukuthi umsebenzisi ngamunye angakwazi ukuqonda ngokushesha ama-nuances olimi futhi adale ngokuzimela uhlelo olunjalo. Ngayo, uzokwazi ukuthumela imiyalo
esikhumulweni se-Quik futhi wenze ukuhlaziya kobuchwepheshe. Luyini ulimi lwesiLua, isifinyezo solimi lohlelo lwe-LUA: https://youtu.be/PbYf6uNZFCE
Idatha yomlando emfushane
I-Lua yasungulwa ngo-1993 ngabahleli bezinhlelo baseBrazil abavela esigabeni se-Tecgraf. Onjiniyela benze isiqiniseko sokuthi umsebenzisi ngamunye angenza izinguquko ezithile ekuthuthukisweni kolimi. Lokhu kungenziwa ngokufinyelela okuvulekile kukhodi. EBrazil, ukuvela kolimi lwayo lokuhlela kwaba ukutholakala kwangempela. Ngempela, ngaphambi kwalokho, leli zwe alizange lizuze impumelelo enjalo emkhakheni wokuthuthukiswa kwekhompyutha.
Ulimi lwakhiwe ngesisekelo se-SOL ne-DEL. Lezi zenzakalo zabona umhlaba ngonyaka ngaphambi kweLua. Inhlangano efanayo yaseBrazil yenza njengombhali. Lezi zilimi zokuhlela zagunyazwa yiPetrobras, inkampani yesifunda esifanayo ebambe iqhaza ekukhishweni nasekusetshenzisweni kukawoyela. Inguqulo yakamuva ye-Lua 5.4.0 ikhishwe muva nje – ngo-2020. Onjiniyela bazama ukwethula izici ezithakazelisayo neziwusizo kuphrojekthi kaningi ngangokunokwenzeka. Ngakho-ke, uhlelo luvuselelwa njalo futhi ludingeka phakathi konjiniyela.
Izici zolimi lohlelo lwe-Lua
Ebhekene ne-Lua, umthuthukisi unikezwa ithuba lokusebenzisa lolu limi, kokubili okwakhelwe ngaphakathi (ngenxa yokuthi lubhaliwe) futhi luzimele (ezimweni ezithile, lungasetshenziswa ngaphandle kwezengezo). Lapho ababhali besebenza ekudalweni kwe-Lua, bahamba ngamabomu ukuze benze ithuluzi lokusebenza elingathathi isikhala esiningi futhi lizosebenza kalula kunoma iyiphi idivayisi.
Abathuthukisi bazama ukwenza lolu limi lube lula ngangokunokwenzeka, ukuze ngisho nabahleli bezinhlelo abaqalayo bakwazi ukuluqonda ngokushesha. Lesi yisidingo esikhuphukile sephrojekthi. Ochwepheshe banethuba lokubhala ikhodi nokudala intuthuko enkulu ngaphandle kokusebenzisa imitapo yolwazi kuwebhusayithi esemthethweni. Ababhali banakekele ukutholakala kwemingcele edingekayo ohlelweni ngokwalo. Abasebenzisi abaqalayo bavame ukufunda ukuthi iziphi izindawo ulimi lwesiLua olusetshenziswa kuzo. Yakhelwe ukukhiqizwa kwezinhlelo emkhakheni wezimboni. Kodwa namuhla, ngosizo lwalolu limi, amarobhothi ahlukahlukene okuhweba, imibhalo, imidlalo yekhompiyutha, izinhlelo zokusebenza, i-bots yeTelegram, njalonjalo. Ngaphezu kwalokho, uLua uhileleke kuhlelo olusha olusiza ukuhlola indawo. Isetshenziswa nasekufundiseni abafundi emanyuvesi. Ulimi lokuhlela oludume kakhulu lwesiLua lubhekwa ekhaya. KuseBrazil lapho isetshenziswa cishe yonke indawo (lapho kungenzeka khona).
Izinzuzo nemibi
Njenganoma yiluphi uhlelo, indlela kanye nolimi lokuhlela lwesiLua lunobuhle nobubi bayo. Kufanelekile ukuqala ngezici ezinhle zentuthuko:
- Ezokuthutha ezisezingeni eliphezulu . Ngokungafani nezinhlelo eziningi, i-Lua kulula ukuyidlulisa isuka ohlelweni olulodwa iye kolunye. Kulokhu, azikho izinguquko ezinkulu. Kunoma yikuphi, ngeke kube namaphutha kukhodi.
- Imitapo yolwazi eminingi . Uma kuqhathaniswa ne- JavaScript , i-Lua inezinketho ezimbalwa kakhulu zelabhulali. Nokho, insiza esemthethweni inakho konke okudingayo ukuze usebenze ngokugcwele ngolimi.
- Ukusebenza kahle . Uhlelo lukuvumela ukuthi wengeze lawo malayibhulali abalulekile enqubweni ethile yokubhala amakhodi ngesikhathi esifushane.
- Ukusebenziseka kalula . Ama-programming gurus adinga kuphela ukufunda imininingwane embalwa yolimi, futhi noma kunjalo angayisebenzisa ngokuphepha ekuthuthukisweni kwawo. Kulabo abasanda kuqala ngokuhlela, akuthathi isikhathi eside ukuqonda isiLua.
- Ukonga inkumbulo enkulu . Ngokwenza izinhlelo ngalolu limi, uchwepheshe uqinisekisiwe ukubona umehluko namanye ama-analogue. Phela, ukuthuthukiswa kwe-Lua kudinga inkumbulo encane kudivayisi.
Okuwukuphela kokubi okuphawulekayo kolimi ukuthi lubhalwe phansi. Futhi lokhu kusho ukuthi imvamisa ingasetshenziswa kuphela ngokuhlangana nezinye izilimi ezithuthukiswayo. Okudume kakhulu kulezi yi-C. Okusho ukuthi, kuzodingeka ufunde olunye ulimi lokuhlela.
Ukuqhathanisa neJavascript
Abasebenzisi abaningi baqhathanisa i-Lua ne-JavaScript, bethi amakhodi abo acishe afane. Kukhona ukufana okuningi phakathi kwezilimi kunomehluko. Kodwa, naphezu kokufana okusobala, kunezinhlobonhlobo eziningi. Isibonelo, i-Lua inokusekelwa kwayo kwesoftware. Kodwa-ke, abathuthukisi beJavaScript basanda kwethula isibuyekezo, ngokusho ukuthi, umsebenzisi udinga nje ukubhala igama elithi “isivuno” phakathi kwama-generator, emva kwalokho uhlelo luzosekelwa.
I-opharetha ye-Lua yokukhuphulela amandla isho uphawu olunjalo “^”, kuyilapho ku-JavaScript ingu-“**”. Eyakamuva inemisebenzi yokusondeza futhi yokuhlehlisa. Kodwa i-Lua ingenza ukulayisha ngokweqile komsebenzisi. I-JavaScript iqukethe imisebenzi eguquguqukayo kuphela, kuyilapho i-Lua izichazile. I-JavaScript ingaziqhayisa ngokusekela izinga le-Unicode elaziwayo. Inhlanganisela ethi “!==” isetshenziselwa ukukhombisa ukungalingani olimini, futhi isiLua sisebenzisa okuthi “~=” ngenjongo efanayo. Eminye umehluko uvezwa etafuleni.
Izici zamarobhothi ezinhlelo zokuhweba ngolimi lwesiLua
Ukudala amarobhothi ku-QLua akunzima neze, ngisho nabaqalayo bangakwazi ukukusingatha. Into eyinhloko ukuqonda i-theory eyisisekelo ekuqaleni. Ukuze uqambe ikhodi, isihleli sombhalo esilula siwusizo. Uhlelo lokudala lufana nokuhlanganiswa kwenkomba. Nokho, kunomehluko ongasho lutho kukhodi ngokwayo. Okunye “okugqamisayo” okuhle – irobhothi elisanda kwenziwa lingabekwa noma yikuphi ku-PC yakho.
Okubalulekile! Kufanele kube nomsebenzi owodwa kuphela kukhodi – “okuyinhloko”.
Uma ikhodi yerobhothi isihlanganisiwe futhi yahlelwa, kuyanconywa ukuthi uyigcine. Ungakhohlwa mayelana nesandiso se-lua. Njengoba sekushiwo, uhlelo lungafakwa noma kuphi kukhompyutha. Ukuze uhlole ikhodi yakho, udinga ukusebenzisa irobhothi. Ukuze wenze lokhu, yiya engxenyeni ethi “Amasevisi”. Phansi kuzoba nomugqa othi “Lua scripts”, kufanele uchofozwe.
Okulandelayo, iwindi elinemibhalo ebhaliwe lizovela. Lapho kufanele ukhethe ifayela elidingekayo bese uliqhuba usebenzisa inkinobho efanele.
Ekugcineni, kunconywa ukuthi uhlole ikhodi ye-bot ukuze uthole amaphutha. Uma konke kuhamba kahle, irobhothi lizoqala. Uma kwenzeka kuba nama-hitches, kufanelekile ukubuyela kukhodi futhi futhi uhlole ukulunga kwayo.
Uhlolojikelele lwamarobhothi okuhweba angcono kakhulu ku-Lua – izixazululo ezenziwe ngomumo zabaqalayo
Usebenzisa ulimi lohlelo lwesiLua, ungakha izinhlobo ezahlukene zamarobhothi anoma yikuphi ukuxaka. Nokho, ungakwazi ukuthenga uhlelo eselenziwe ngomumo. Kuhlongozwa ukujwayelana nama-algorithms aziwayo asevele elungele ukusebenza. Ungawathenga noma uzame inguqulo yedemo. Gcwalisa irobhothi lokuhweba letheminali ye-QUIK e-Lua: https://youtu.be/Z2xzOfNZFso
I-Robot-terminal “Delta Pro”
Ikuvumela ukuthi wenze kusebenze okungaba ngu-120 noma yiziphi izinketho endaweni eyodwa. Kulesi simo, ungasebenzisa izinhlobo ezahlukene zamasu namathuluzi.
I-RQ: Iphesenti elilodwa
Irobhothi lenzelwe ukuhweba emkhakheni wokuhweba. I-algorithm ikuvumela ukuthi ukhuphule imali engenayo kulo msebenzi izikhathi eziningana. Izingozi ziyancipha, zingabalwa kalula.
RQ: UMartin
Isistimu ikuvumela ukubala inkatho ngaphambi kokwenza isivumelwano. Ukuhweba ngemodi “ye-semi-automatic” kunikezwa. Amazinga angalandelelwa ngempumelelo futhi asethwe mathupha.
Izinhlobo zemibhalo ye-Lua yetheminali ye-QUIK
Lapho kwenziwa umsebenzi othile kutheminali ye-QUIK, kusetshenziswa imibhalo elandelayo:
- Imibhalo ye-Lua . Angagcinwa kunethiwekhi, kudiski yendawo, noma kwenye indawo lapho ezofinyeleleka khona kutheminali. Zisebenza ngokwanele ukudala irobhothi lokuhweba ngosizo lwazo. Kuzokwazi ukudala amatafula ku-QUIK, sebenzisa izinketho zamathuluzi, unikeze imiyalo yokwenza imisebenzi ehlukahlukene, njalonjalo.
- Izinkomba zangokwezifiso . Lapha, uma kuqhathaniswa nokubuka kwangaphambilini, ukusebenza kuncane kakhulu. Uhlelo luhloselwe umsebenzisi ukuthi abonise i-algorithm yezenzo kumashadi wetheminali.
Ukuhlela ngesi-Lua kulabo abafuna ukufunda kahle ulimi – landa umhlahlandlela ophelele:
Ukuhlela ngamarobhothi e-Lua e-Lua ukuze uthole i-QUIK – irobhothi lase-Iceberg: https://youtu.be/cxXwF_xmTHY
Ungabhala kanjani irobhothi ngesiLua
Ngemva kokunquma ukudala irobhothi lakhe, umsebenzisi kufanele alandele i-algorithm ehlanganiswe ngaphambilini. Lapho ezuza ulwazi lwezinhlelo, uzokwazi ukubhala kalula amakhodi akhe nokuhlola. Ngokukhetha uLua ukufunda le ndawo, oqalayo ngeke enze iphutha. Phela, ekuqaleni, into esemqoka ukuyeka ngolimi olulula noluqondakalayo lokuhlela. Ukuze uqalise, vula uhlelo lwetheminali yokuhweba lwe-QUIK. Ewindini layo, udinga ukudala ifolda. Lena indawo lapho zonke izikripthi ezibhaliwe zizogcinwa khona. Umsebenzisi anganikeza ifolda noma yiliphi igama, kodwa kufanele libe nezinhlamvu zesiLatini kuphela. Ake sithi igama layo “LuaScripts”. Okulandelayo, udinga ukwenza ifolda isebenze futhi udale umhleli wombhalo lapho, isibonelo, i-Notepad. Esikhaleni esingenalutho (ngaphakathi kwewindi lohlelo) udinga ukuchofoza kwesokudla
. Ibhokisi lengxoxo lizovela, ohlwini okufanele ukhethe ithebhu ethi “Dala”, bese kuba irowu ethi “Idokhumenti Yombhalo”.
Kufanele futhi inikezwe igama, ukuze ingadideki kamuva. Isibonelo, ungabhala “Script_N1”. Ungakhohlwa mayelana nesinqumo solimi olusetshenzisiwe – .lua. Okusho ukuthi, umsebenzisi kufanele athole umbhalo onjalo kudokhumenti ethi “Script_N1.lua”. Nokho, iWindows ivamise ukushintsha isandiso ngokuzenzakalelayo ngokufaka ifayela elithi .txt. Kulokhu, kunconywa ukuthi udale idokhumenti ku-NotePad ++, ukusetha isinqumo esidingekayo. Kulolu hlelo, uzodinga ukukhetha ingxenye ethi “Syntaxes”. Ibhokisi lengxoxo elinezinketho ezimbalwa lizovela lapha. Uzodinga ukukhetha “L”. Ukusuka lapho, elinye iwindi lizovela lapho udinga uchofoze ku- “Lua”.
Ngemva kwalokho, kumenyu efanayo, kanye nesigaba esithi “Syntaxes”, kufanele uchofoze ingxenye ethi “Ifayela”. Ewindini elilandelayo kuzoba nombhalo – “Gcina njenge”. Umsebenzisi udinga ukuchofoza kuyo futhi alinde kuze kuvuleke iwindi elisha.
Lapho, phezulu, umugqa onegama lefolda edalwe ngaphambilini “Imibhalo ye-Lua” izobonakala. Phansi kwewindi, amanye amadokhumenti ama-2 adalwe ngumsebenzisi ayaboniswa. Uma konke kufana, kufanele uqinisekise isenzo futhi ulondoloze isimo samanje sekhodi.
Isinyathelo esilandelayo ukubhala ikhodi ngolimi olukhethiwe lokuhlela lwesiLua. Abaqalayo bangasebenzisa imfundo, kuzosiza ukudala ikhodi elula, ukuze uchwepheshe azame isandla sakhe. I-algorithm yezenzo itholakala kufayela lohlelo elibizwa nge-QLUA.chm. Kuhlongozwa, isibonelo, ukubhala ikhodi engasindi enjalo:
function main()
message(“Iskripthi sami sokuqala sethuliwe”);
ekugcineni Okulandelayo, udinga ukuchofoza inkinobho yokulondoloza kumenyu.
Ikhodi kufanele ilondolozwe kufayela elithi “Script_N1.lua”. Siyethula futhi sibone ukuthi iskripthi sokuqala siboniswa kanjani. Ukuyivula ku-QUIK, udinga ukuvula lolu hlelo bese ukhetha ithebhu ethi “Amasevisi” engxenyeni yezinketho. Okulandelayo, ibhokisi lengxoxo lizovela, lapho kufanele uchofoze ku-“LUA scripts …”.
Ngemva kwalokho umsebenzisi uzobona ifolda “Izikripthi ezitholakalayo”. Phezulu kwesokudla kukhona inkinobho ethi Engeza. Yichofoze bese ubheka ifayela elinekhodi. Itholakala lapha “Script_N1.lua”.
Lapho uvula idokhumenti, kubalulekile ukukhetha umugqa “Script_N1.lua” (kufanele ugcinwe ku-drive C), bese, ngezansi, chofoza inkinobho ethi “Run”.
Iwindi elisha lizovela ngokushesha.
Ukuze ugweme lezi zinhlamvu ezingaqondakali, udinga ukuya ohlelweni lwe-NotePad. Kuzilungiselelo kukhona isigaba “Encodings”, chofoza kuso. Bese kuzovela uhlu lwamathebhu, phakathi kwawo okufanele uchofoze okuthi “Guqula ube yi-ANSI”.
Okulandelayo, kufanele uchofoze inkinobho yokulondoloza bese ubuyela efasiteleni lomlayezo. Sekuzoba khona omunye umbhalo, hhayi umugqa onezinhlamvu.
Ungahlela kanjani ku-LUA ku-terminal ye-QUIK
Kunezindlela ezi-3 ezidumile:
- Noma yiliphi ifayela lombhalo liyadalwa, lapho kufanele kubekwe khona isandiso se-.lua. Okulandelayo, udinga ukuvula isihleli bese ubhala ikhodi. Ngemuva kokuqala, i-algorithm enjalo izokwenziwa kanye kuphela. Ungakwazi ukuyiqhuba ngesandla unomphela. Ungayisebenzisela ukubala kanyekanye ulwazi oluthile.
- Kuskripthi se-Lua ngokwaso, udinga ukudala umsebenzi obizwa ngokuthi main() . Ngaphezu kwalokho, emsebenzini ofanayo, udinga ukufaka ikhodi ebhaliwe. Futhi umsebenzi we- sleep() uwusizo ukumisa okwesikhashana umbhalo noma, ngokuphambene, uwuqalise kabusha. Okusho ukuthi, uma wenza kusebenze umsebenzi oyinhloko (), bese ufaka umsebenzi wokulala (), uzokwazi ukuzuza ukubala ngobuningi besikhawu sesikhathi esithile.
- Kuhlelo lwe-QLUA, ungasebenzisa imodeli yokuthuthukisa eqhutshwa umcimbi. Ngakho-ke, manje akudingekile “ukubona” izinguquko emsebenzini owodwa futhi, ngenxa yalokhu, yenza imiyalo elandelayo.
Kuhlongozwa ukuhlaziya indlela yokugcina ngokuningiliziwe. Ukuze uphathe umcimbi othile, kufanele ubhale umsebenzi kusikripthi esisheshayo. Ungasebenzisa lolu hlelo olulandelayo:
Isikripthi se-LUA singaqukatha imisebenzi eminingana enamagama akhethekile: isivumelwano, izingcaphuno, njalonjalo. Udinga ukuthola ingxenye ethi “Amathebula” ohlelweni, iya kokuthi “Lua”. Ibhokisi lengxoxo lizovela lapho futhi umugqa “Imibhalo Etholakalayo” izobonakala, chofoza kuyo. Okulandelayo, chofoza ithebhu “Yethula”. Bese kuza ukucutshungulwa kanye nokwenziwa komsebenzi oyisibopho
() oyinhloko . Bese, udinga ukumemezela
is_run , umsebenzi uzoqukatha inani
eliyiqinisokuze kube yilapho umsebenzisi evula inkinobho ethi Stop Script. Bese ukuguquguquka komsebenzi kuya kumodi engamanga ngaphakathi kwe-OnStop(). Ngemuva kwalokho, umsebenzi oyinhloko () uyaphela, futhi iskripthi ngokwaso siyama. Umbhalo obhaliwe kufanele ulondolozwe futhi uqalise. Lapho wenza ukuthengiselana, umsebenzisi uzobona idatha yendawo ngayinye kanye nenani lokugcina lemisebenzi.
Ukuze usebenzise i-QLua Ngokushesha, udinga ukuyidlulisela kufolda entsha ku-PC yakho. Ungabiza noma yini oyithandayo, isibonelo, “MyLua”. Zonke izikripthi ze-Lua zizogcinwa lapho. Ngemva kokufaka i-QUIK, udinga ukuvula ingxenye ethi “Amasevisi”, bese uchofoza kuthebhu ethi “Lua scripts”. Ewindini elivulayo, vula inkinobho ethi “Engeza”. Bese udinga ukukhetha iskripthi bese usivula. Izoba sengxenyeni ethi “Izikripthi Ezilandiwe”. Khona-ke kufanele ugqamise umugqa weskripthi bese uchofoza “Run”. Ukumisa iskripthi, vele uchofoze okuthi “Misa”. [i-id yamagama-ncazo = “okunamathiselwe_1215″ align=”aligncenter” wide=”1919″]
I-Bot ye-Quik ku-LUA[/caption]
Ungasifaka kanjani isikripthi se-LUA endaweni yokuhweba
Ukuqeqeshwa kanye namatheminali ajwayelekile adinga i-algorithm efanayo yokufaka irobhothi lokuhweba:
- Kudingekile ukuchofoza kusigaba esithi “Amasevisi” kumenyu ephezulu yetheminali.
- Okulandelayo, thola inkinobho ethi “LUA scripts” ebhokisini lengxoxo elidonsela phansi bese uchofoza:
- Ngaleso sikhathi, iwindi elithi “Izikripthi Ezitholakalayo” kufanele livele. Bese, kufanele wenze kusebenze inkinobho ethi “Engeza” bese ukhetha ifayela lerobhothi elidingekayo lokuhweba.
Ukuthatha idatha eshadini le-Lua elinombhalo kutheminali ye-Quik: https://youtu.be/XVCZAnWoA8E Lua inketho enhle yokufunda ukuhlela kanye nempumelelo esikhathini esizayo. Into esemqoka ukuthi ungayeki kuphela ekufundeni inkolelo. Kungcono ukufunda ukwaziswa ngokuhlala uprakthiza. Ngemva kwesikhathi esithile, umthuthukisi uzoqala ukuthuthuka futhi akwazi ukudala umkhiqizo wakhe obalulekile.