Ukusebenzisa ulwimi lwenkqubo yeLua, unokwenza imidlalo eyahlukeneyo, izinto eziluncedo,
iirobhothi zokurhweba kunye nolunye uphuhliso. Ulwimi lwesiLua kulula ukuluqonda, lunetoliki edumileyo. Kucetywayo ukuba uqhelane noLua ngokusondeleyo, kunye nokufunda indlela yokubhala irobhothi yokurhweba okanye iskripthi ngolu lwimi.
- Luluphi ulwimi lwesiLua kwaye luluncedo njani?
- Idatha emfutshane yembali
- Iimpawu zolwimi lwenkqubo yesiLua
- Izinto eziluncedo nezingeloncedo
- Ukuthelekisa kunye neJavascript
- Iimpawu zeerobhothi zokucwangcisa ukurhweba ngolwimi lwesiLua
- Amagqabantshintshi eerobhothi ezingcono kakhulu zokurhweba kwi-Lua – izisombululo esele zilungele abaqalayo
- I-Robot-terminal “Delta Pro”
- RQ: Ipesenti enye
- RQ: UMartin
- Iindidi zezikripthi zeLua ze-terminal yeQUIK
- Indlela yokubhala irobhothi eLua
- Uyenza njani inkqubo kwi-LUA kwi-terminal ye-QUIK
- Indlela yokufaka iscript seLUA kwi-terminal yokurhweba
Luluphi ulwimi lwesiLua kwaye luluncedo njani?
IsiLua lulwimi olusebenzisekayo olulula ukulusebenzisa. Abaqalayo bavuma ukuba ngoncedo lwayo, unokufunda iziseko zeprogram ngexesha elifutshane. IsiLua sidityaniswe ngempumelelo nophuhliso oluqulunqwe ngolunye ulwimi. Kuhlala kucetyiswa kubafundi abasaqalayo kwisayensi yoyilo lwe-elektroniki.
Ulwimi lwesiLua ludla ngokusetyenziswa kwiinkalo ezahlukeneyo. Inokuba luncedo:
- Umsebenzisi odlala imidlalo yekhompyutha (bhala iiplagi).
- Ingcali yophuhliso lwemidlalo (ukuphuhlisa injini).
- Umdwelisi wophuhliso lwesicelo (bhala iiplagi zezixhobo ezahlukeneyo).
- Umbhekisi phambili kwicala lokuzinziswa (ulwimi alucothi inkqubo kwaye lukuvumela ukuba usebenze ngokufanelekileyo)
- Abarhwebi bokubhala izikripthi kunye ne-bots yokuthengisa.
Enkosi kuLua, ngaphezulu kwerobhothi enye yokurhweba yenziwe. Inzuzo kukuba umsebenzisi ngamnye unokuqonda ngokukhawuleza i-nuances yolwimi kwaye enze ngokuzimeleyo inkqubo enjalo. Ngayo, kuya kwenzeka ukuthumela imiyalelo kwi
-terminal ye-Quik kwaye wenze uhlalutyo lobugcisa. Loluphi ulwimi lwesiLua, isishwankathelo solwimi lwenkqubo yeLUA: https://youtu.be/PbYf6uNZFCE
Idatha emfutshane yembali
I-Lua yasungulwa ngo-1993 ngabaprogram baseBrazil abavela kwicandelo leTecgraf. Abaphuhlisi baqinisekisa ukuba umsebenzisi ngamnye unokwenza izilungiso ezithile kuphuhliso lolwimi. Oku kunokwenziwa ngofikelelo oluvulekileyo kwikhowudi. EBrazil, ukuvela kolwimi lwayo lokucwangcisa kwaba yinto efunyenwe ngokwenene. Enyanisweni, ngaphambi koko, eli lizwe alizange liphumelele kwinkalo yophuhliso lwekhompyutheni.
Ulwimi lwenziwe ngesiseko se-SOL kunye ne-DEL. Olu phuhliso lwabona ihlabathi kunyaka ongaphambi kweLua. Umbutho ofanayo waseBrazil wenza njengombhali. Ezi lwimi zeprogram zagunyaziswa yiPetrobras, inkampani yelizwe elifanayo elibandakanyekayo ekutsalweni nasekuqhubeni ioli. Inguqulelo yamva nje yeLua 5.4.0 ikhutshwe kutsha nje – ngo-2020. Abaphuhlisi bazama ukwazisa izinto ezinomdla neziluncedo kwiprojekthi rhoqo kangangoko kunokwenzeka. Ke ngoko, inkqubo ihlaziywa rhoqo kwaye ifunwa phakathi kwabaphuhlisi.
Iimpawu zolwimi lwenkqubo yesiLua
Ejongene noLua, umphuhlisi unikezwa ithuba lokusebenzisa olu lwimi, zombini eyakhelwe ngaphakathi (ngenxa yokuba ibhaliwe) kunye ne-standalone (kwiimeko ezithile, ingasetyenziselwa ngaphandle kokongeza). Xa ababhali basebenza ekudalweni kweLua, bahamba ngamabomu ukwenza isixhobo sokusebenza esingathathi indawo enkulu kwaye siya kusebenza ngokulula kuso nasiphi na isixhobo.
Abaphuhlisi bazama ukululula olu lwimi kangangoko kunokwenzeka, ukwenzela ukuba nabadwelisi benkqubo abaqalayo bakwazi ukuluqonda ngokukhawuleza. Oku kukwanda kwemfuno yeprojekthi. Iingcali zinethuba lokubhala ikhowudi kunye nokudala uphuhliso olukhulu ngaphandle kokubhenela kumathala eencwadi kwiwebhusayithi esemthethweni. Ababhali banakekele ukufumaneka kweeparitha eziyimfuneko kwiprogram ngokwayo. Abasebenzisi be-novice bavame ukufunda ukuba zeziphi iindawo ezisetyenziswa ulwimi lwesiLua. Yenzelwe ukuveliswa kweenkqubo kwicandelo loshishino. Kodwa namhlanje, ngoncedo lolu lwimi, iirobhothi ezahlukeneyo zokurhweba, izikripthi, imidlalo yekhompyuter, izicelo, i-bots yeTelegram, njalo njalo. Ukongeza, uLua ubandakanyeka kubuchule obutsha obunceda ukuphonononga indawo. Ikwasetyenziswa ekufundiseni abafundi kwiidyunivesithi. Olona lwimi ludumileyo lwenkqubo yesiLua lujongwa ekhaya. KuseBrazil ukuba isetyenziswa phantse kuyo yonke indawo (apho kunokwenzeka).
Izinto eziluncedo nezingeloncedo
Njengayo nayiphi na inkqubo, indlela kunye nolwimi lwenkqubo yeLua inenani leenzuzo kunye nokubi. Kufanelekile ukuqala ngemiba emihle yophuhliso:
- Uthutho olusemgangathweni . Ngokungafaniyo neenkqubo ezininzi, i-Lua kulula ukuyihambisa ukusuka kwinkqubo enye ukuya kwenye. Kule meko, akukho zinguqu ezinkulu. Kwimeko nayiphi na into, akuyi kubakho iimpazamo kwikhowudi.
- Amathala eencwadi amaninzi . Xa kuthelekiswa neJavaScript , iLua inokhetho lwethala leencwadi elincinci kakhulu. Nangona kunjalo, isibonelelo esisemthethweni sinayo yonke into oyifunayo ukuze usebenze ngokupheleleyo ngolwimi.
- Ukusebenza kakuhle . Inkqubo ikuvumela ukuba ungeze ezo thala leencwadi ezibalulekileyo kwinkqubo ethile yokurekhoda ngexesha elifutshane.
- Ukusebenziseka lula . I-programming gurus ifuna kuphela ukufunda iinkcukacha ezimbalwa zolwimi, kwaye nangona kunjalo banokuyisebenzisa ngokukhuselekileyo kuphuhliso lwabo. Kwabo baqala ngenkqubo, ayithathi xesha lide ukuqonda isiLua.
- Ugcino lwenkumbulo enkulu . Ngokwenza iinkqubo ngolu lwimi, ingcali iqinisekisiwe ukuba ibone umahluko kunye nezinye ii-analogues. Emva kwayo yonke loo nto, uphuhliso lweLua lufuna imemori encinci kwisixhobo.
Ekuphela kwengxaki ebalulekileyo yolwimi kukuba lubhalwe. Kwaye oku kuthetha ukuba kaninzi inokusetyenziswa kuphela ngokudityaniswa nezinye iilwimi zophuhliso. Eyona idumileyo kwezi yi C. Oko kukuthi, kuya kufuneka ufunde ulwimi olongezelelweyo lokuprograma.
Ukuthelekisa kunye neJavascript
Abasebenzisi abaninzi bathelekisa uLua neJavaScript, besithi iikhowudi zabo ziphantse zifane. Ngokwenene kukho ukufana ngakumbi phakathi kweelwimi kunomahluko. Kodwa, nangona kukho ukufana okucacileyo, kukho iiyantlukwano ezininzi. Umzekelo, uLua unenkxaso yayo yesoftware. Nangona kunjalo, abaphuhlisi beJavaScript basandul ‘ukwazisa ukuhlaziywa, ngokubhekiselele kuyo, umsebenzisi ufuna nje ukubhala igama elithi “isivuno” phakathi kweejeneretha, emva koko inkqubo iya kuxhaswa.
Umsebenzisi weLua wokunyusela kumandla ubonisa uphawu olunjalo “^”, ngelixa kwiJavaScript ingu “**”. Eyokugqibela inemisebenzi yokusondeza kwaye yandeze ngaphandle. Kodwa uLua unokwenza ukulayisha ngaphezulu komsebenzisi. I-JavaScript iqulethe imisebenzi eguquguqukayo kuphela, ngelixa i-Lua inayo echaziweyo. IJavaScript inokuqhayisa ngokuxhasa umgangatho owaziwayo we-Unicode. Indibaniselwano “!==” isetyenziselwa ukubonisa ukungalingani kulwimi, kwaye isiLua sisebenzisa “~=” ngeenjongo ezifanayo. Ezinye iiyantlukwano zinikwe kwitheyibhile.
Iimpawu zeerobhothi zokucwangcisa ukurhweba ngolwimi lwesiLua
Ukudala iirobhothi kwi-QLua akunzima konke konke, nabaqalayo banako ukuyiphatha. Into ephambili kukuqonda i-theory esisiseko kwasekuqaleni. Ukuze ubhale ikhowudi, umhleli wombhalo olula uluncedo. Iskimu sokudala sifana nokuhlanganiswa kwesalathisi. Nangona kunjalo, kukho umehluko ongabalulekanga kwikhowudi ngokwayo. Enye “igqabantshintshi” elungileyo – irobhothi esanda kwenziwa inokubekwa naphi na kwiPC yakho.
Kubalulekile! Kufuneka kubekho umsebenzi omnye kuphela kwikhowudi – “engundoqo”.
Nje ukuba ikhowudi yerobhothi ihlanganiswe kwaye ihlelwe, kuyacetyiswa ukuba uyigcine. Musa ukulibala malunga nolwandiso lwe-lua. Njengoko sele kukhankanyiwe, inkqubo inokubekwa naphi na kwikhompyuter. Ukuvavanya ikhowudi yakho, kufuneka usebenzise irobhothi. Ukwenza oku, yiya kwicandelo elithi “IiNkonzo”. Emazantsi kuya kubakho umgca “Lua scripts”, kufuneka ucofe.
Okulandelayo, ifestile enemibhalo eshicilelweyo elayishiweyo iya kuvela. Apho kufuneka ukhethe ifayile efunekayo kwaye uyiqhube usebenzisa iqhosha elifanelekileyo.
Ekugqibeleni, kuyacetyiswa ukuba ujonge ikhowudi ye-bot yeempazamo. Ukuba konke kulungile, irobhothi iya kuqala. Kwimeko yokubetha, kuyafaneleka ukubuyela kwikhowudi kwakhona kwaye ujonge ukuchaneka kwayo.
Amagqabantshintshi eerobhothi ezingcono kakhulu zokurhweba kwi-Lua – izisombululo esele zilungele abaqalayo
Ukusebenzisa ulwimi lweprogram ye-Lua, unokwenza iintlobo ezahlukeneyo zeerobhothi zaluphi na ubunzima. Nangona kunjalo, unokuthenga inkqubo esele yenziwe. Kucetywayo ukuba uqhelane ne-algorithms eyaziwayo esele ilungele ukusebenza. Unokuzithenga okanye uzame uguqulelo lwedemo. Gqibezela irobhothi yokurhweba kwitheminali yeQUIK eLua: https://youtu.be/Z2xzOfNZFso
I-Robot-terminal “Delta Pro”
Ikuvumela ukuba uvule malunga ne-120 naluphi na ukhetho kwiqonga elinye. Kule meko, ungasebenzisa iintlobo ezahlukeneyo zezicwangciso kunye nezixhobo.
RQ: Ipesenti enye
Irobhothi yenzelwe ukurhweba kwindawo yokurhweba. I-algorithm ikuvumela ukuba ukwandise ingeniso kulo msebenzi ngamaxesha amaninzi. Imingcipheko iyancitshiswa, ingabalwa ngokulula.
RQ: UMartin
Inkqubo ikuvumela ukubala iqashiso ngaphambi kokwenza isivumelwano. Urhwebo kwi “semi-automatic” mode lubonelelwe. Amanqanaba angalandelelwa ngempumelelo kwaye abekwe ngesandla.
Iindidi zezikripthi zeLua ze-terminal yeQUIK
Xa usenza umsebenzi othile kwi-terminal ye-QUIK, ezi scripts zilandelayo ziyasetyenziswa:
- Imibhalo yesiLua . Ziyakwazi ukugcinwa kuthungelwano, kwidiski yendawo, okanye kwenye indawo apho ziya kufumaneka khona kwi-terminal. Zisebenza ngokwaneleyo ukwenza irobhothi yokurhweba ngoncedo lwabo. Kuya kwenzeka ukwenza iitafile kwi-QUIK, sebenzisa iinketho zesixhobo, ukunika imiyalelo yokwenza imisebenzi eyahlukeneyo, njalo njalo.
- Iimpawu eziqhelekileyo . Apha, xa kuthelekiswa nombono wangaphambili, kuncinci kakhulu ukusebenza. Inkqubo yenzelwe ukuba umsebenzisi abonise i-algorithm yezenzo kwiitshathi ze-terminal.
Ukucwangcisa ngesiLua kwabo bafuna ukuqonda ulwimi ngokucokisekileyo – khuphela isikhokelo esipheleleyo:
Ukucwangcisa kwiLua Robots eLua yeQUIK – irobhothi ye-Iceberg: https://youtu.be/cxXwF_xmTHY
Indlela yokubhala irobhothi eLua
Emva kokuba egqibe ukwenza irobhothi yakhe, umsebenzisi kufuneka alandele i-algorithm ehlanganiswe kwangaphambili. Xa efumana amava kwinkqubo, uya kuba nako ukubhala iikhowudi zakhe ngokulula kunye nokulinga. Ngokukhetha uLua ukuba afunde le ndawo, umntu oqalayo akayi kuphosisa. Emva kwakho konke, ekuqaleni, into ephambili kukuyeka kulwimi olulula noluqondakalayo lwenkqubo. Ukuqalisa, vula inkqubo yorhwebo ye-QUIK. Kwifestile yayo, kufuneka wenze ifolda. Le yindawo apho zonke izikripthi ezibhaliweyo ziya kugcinwa khona. Umsebenzisi unokunika ifolda ngokupheleleyo naliphi na igama, kodwa kufuneka iqulathe kuphela oonobumba besiLatini. Masithi igama layo ngu “LuaScripts”. Emva koko, kufuneka uvule ifolda kwaye wenze umhleli wombhalo apho, umzekelo, i-Notepad. Kwisithuba esingenanto (ngaphakathi kwefestile yeprogram) kufuneka ucofe ekunene
. Ibhokisi yencoko yababini iya kuvela, kuluhlu okufuneka ukhethe ithebhu ethi “Yenza”, kwaye emva koko umqolo we “Text Document”.
Kufuneka kwakhona kunikwe igama, ukuze ungabhideki kamva. Umzekelo, ungabhala “Script_N1”. Musa ukulibala malunga nesisombululo solwimi olusetyenzisiweyo – .lua. Oko kukuthi, umsebenzisi kufuneka afumane umbhalo onjalo kuxwebhu “Script_N1.lua”. Nangona kunjalo, iWindows ihlala ilutshintsha ulwandiso ngokuzenzekelayo ngokufaka ifayile ye-.txt. Kule meko, kucetyiswa ukuba wenze uxwebhu kwi-NotePad ++, ukubeka isisombululo esifunekayo. Kule nkqubo, kuya kufuneka ukhethe icandelo elithi “Syntaxes”. Ibhokisi yencoko yababini enokhetho oluninzi izakuvela apha. Kuya kufuneka ukhethe “L”. Ukusuka apho, enye ifestile iya kuvela apho kufuneka ucofe ku “Lua”.
Emva koko, kwimenyu efanayo, kunye necandelo elithi “Syntaxes”, kufuneka ucofe kwindawo ethi “Ifayile”. Kwifestile elandelayo kuya kubakho umbhalo – “Gcina njenge”. Umsebenzisi kufuneka acofe kuyo kwaye alinde de kuvulwe ifestile entsha.
Apho, phezulu, kuya kubonakala umgca onegama lefolda eyenziwe ngaphambili “Lua scripts”. Emazantsi efestile, amanye amaxwebhu ama-2 awenziwe ngumsebenzisi abonisiwe. Ukuba yonke into ihambelana, kufuneka uqinisekise isenzo kwaye ugcine imo yangoku yekhowudi.
Isinyathelo esilandelayo kukubhala ikhowudi kulwimi olukhethiweyo lweLua. Abaqalayo banokusebenzisa umyalelo, kuya kunceda ukwenza ikhowudi elula, ukuze ingcali izame isandla sayo. I-algorithm yezenzo ibekwe kwifayile yeprogram ebizwa ngokuba yi-QLUA.chm. Kucetywayo, umzekelo, ukubhala ikhowudi ekhaphukhaphu ngolu hlobo:
umsebenzi ongundoqo ()
umyalezo(“Iskripthi sam sokuqala siqalisiwe”);
ekupheleni Okulandelayo, kufuneka ucofe iqhosha lokugcina kwi menu.
Ikhowudi kufuneka igcinwe kwifayile “Script_N1.lua”. Siyayisungula kwaye sibone indlela iskripthi sokuqala esiboniswa ngayo. Ukuyivula kwi-QUIK, kufuneka uvule le nkqubo kwaye ukhethe ithebhu ethi “IiNkonzo” kwicandelo lokukhetha. Okulandelayo, ibhokisi yencoko yababini iya kuvela, apho kufuneka ucofe ku-“LUA scripts …”.
Emva koko umsebenzisi uya kubona ifolda “Izikripthi ezifumanekayo”. Kwicala eliphezulu lasekunene yi Yongeza iqhosha. Cofa kwaye ujonge ifayile enekhowudi. Ibekwe apha “Script_N1.lua”.
Xa uvula uxwebhu, kubalulekile ukukhetha umgca “Script_N1.lua” (kufuneka ugcinwe kwi-drive C), ngoko, ezantsi, nqakraza kwiqhosha elithi “Run”.
Ifestile entsha iya kuvela ngoko nangoko.
Ukuze ugweme ezi mpawu zingaqondakaliyo, kufuneka uye kwiprogram ye-NotePad. Kuseto kukho icandelo elithi “Encodings”, cofa kuyo. Emva koko uluhlu lweethebhu luya kuvela, phakathi apho kufuneka ucofe ku “Guqula kwi-ANSI”.
Okulandelayo, kufuneka ucofe kwiqhosha lokugcina kwaye ubuyele kwifestile yomyalezo. Kuya kuba sele kukho omnye umbhalo, kwaye hayi umqolo onezikrikri.
Uyenza njani inkqubo kwi-LUA kwi-terminal ye-QUIK
Kukho iindlela ezi-3 ezidumileyo:
- Nayiphi na ifayile yokubhaliweyo yenziwe, apho ulwandiso lwe.lua kufuneka lubekwe. Okulandelayo, kufuneka uvule umhleli kwaye ubhale ikhowudi. Emva kokuqala, i-algorithm enjalo iya kwenziwa kube kanye kuphela. Ungayiqhuba ngesandla ngokungenasiphelo. Ungayisebenzisa ukubala ixesha elinye lolwazi oluthile.
- Kumbhalo weLua ngokwawo, kufuneka wenze umsebenzi obizwa ngokuba yi main() . Ukongezelela, kumsebenzi ofanayo, kufuneka ufake ikhowudi ebhaliweyo. Kwaye ubuthongo () umsebenzi luncedo ukumisa okwexeshana okushicilelweyo okanye, ngokuchaseneyo, qalisa kwakhona. Oko kukuthi, ukuba wenza umsebenzi ongundoqo () usebenze, kwaye emva koko ufake ubuthongo () umsebenzi, uya kukwazi ukufezekisa ubalo ngokuphindaphindiweyo kwexesha elithile lekhefu.
- Kwinkqubo ye-QLUA, ungasebenzisa imodeli yophuhliso eqhutywa ngumsitho. Ngaloo ndlela, ngoku akukho mfuneko “ukubona” utshintsho kumsebenzi omnye kwaye, ngenxa yoko, yenza le miyalelo ilandelayo.
Kucetywa ukuhlalutya le ndlela yokugqibela ngokweenkcukacha ngakumbi. Ukusingatha isiganeko esithile, kufuneka ubhale umsebenzi kwiskripthi ngokukhawuleza. Ungasebenzisa olu dweliso lulandelayo:
Iscript seLUA sinokuquka imisebenzi emininzi enamagama akhethekileyo: deal, quotes, njalo njalo. Kufuneka ufumane icandelo elithi “Iitheyibhile” kwiprogram, yiya ku “Lua”. Ibhokisi yencoko yababini iya kuvela apho kwaye umgca “Izikripthi ezifumanekayo” ziya kubonakala, cofa kuyo. Okulandelayo, cofa kwi “Launch” tab. Emva koko kuza uqwalaselo kunye nokuphunyezwa kwe obligatory
main () umsebenzi . Emva koko, kufuneka
uchaze is_run , umsebenzi uya kuqulatha ixabiso
eliyinyanide umsebenzisi avule iqhosha le-Stop Script. Emva koko uguqulo lomsebenzi lungena kwindlela yobuxoki ngaphakathi kwi-OnStop (). Emva koko, owona msebenzi () uyaphela, kwaye iskripthi ngokwaso siyayeka. Iscript esibhaliweyo masigcinwe kwaye siqhutywe. Xa usenza ukuthengiselana, umsebenzisi uya kubona idatha kwiqashiso ngalinye kunye nesixa sokugqibela sentengiselwano.
Ukusebenzisa i-QLua ngokukhawuleza, kufuneka uyidlulisele kwifolda entsha kwiPC yakho. Ungayibiza nantoni na oyithandayo, umzekelo, “MyLua”. Zonke iincwadi zeempendulo zeLua ziya kugcinwa apho. Wakuba ungenile iQUIK, kufuneka uvule icandelo elithi “IiNkonzo”, emva koko ucofe ku-“Lua scripts” thebhu. Kwifestile evulayo, vula iqhosha elithi “Yongeza”. Emva koko kufuneka ukhethe iskripthi kwaye usivule. Iya kuba kwicandelo elithi “Izikripthi eziKhutshelweyo”. Emva koko kuya kufuneka uqaqambise umgca weskripthi kwaye ucofe u “Run”. Ukuyekisa iskripthi, cofa nje u-“Misa”.
Indlela yokufaka iscript seLUA kwi-terminal yokurhweba
Uqeqesho kunye neetheminali eziqhelekileyo zifuna i-algorithm efanayo yokufaka irobhothi yokurhweba:
- Kuyimfuneko ukucofa icandelo elithi “IiNkonzo” kwimenyu ephezulu ye-terminal.
- Okulandelayo, fumana iqhosha elithi “LUA scripts” kwibhokisi yencoko yababini eyehlayo kwaye ucofe:
- Ngelo xesha, ifestile ethi “Izikripthi ezikhoyo” kufuneka zivele. Emva koko, kuya kufuneka uvule iqhosha elithi “Yongeza” kwaye ukhethe ifayile yerobhothi efunekayo yokurhweba.
Ukuthatha idatha kwitshathi yesiLua ngeskripthi kwi-terminal ye-Quik: https://youtu.be/XVCZAnWoA8E Lua lukhetho olukhulu lokufunda inkqubo kunye nempumelelo kwixesha elizayo. Into ephambili ayiyikuyeka kuphela ekufundeni ingcamango. Kungcono ukufunda umbandela ngokuziqhelanisa rhoqo. Emva kwexesha elithile, umphuhlisi uya kuqala ukwenza inkqubela kwaye akwazi ukwenza imveliso yakhe efanelekileyo.