Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesa

Программирование

Uchishandisa mutauro weLua programming, unogona kugadzira mitambo yakasiyana-siyana, zvishandiso,
marobhoti ekutengesa uye zvimwe zvinobudirira. Mutauro weLua uri nyore kunzwisisa, une muturikiri ane mukurumbira. Zvinokurudzirwa kujairana neLua pedyo, pamwe nekudzidza kunyora robhoti yekutengesa kana script mumutauro uyu.

Chii chinonzi Lua mutauro uye chinobatsira sei?

Lua mutauro uri nyore kushandisa unobatika. Vatangi vekutanga vanobvuma kuti nerubatsiro rwayo, unogona kudzidza izvo zvekutanga zvehurongwa munguva pfupi. Lua inobatanidzwa zvinobudirira nebudiriro dzakaunganidzwa mune mumwe mutauro. Inowanzo kukurudzirwa kuvadzidzi vari kutanga mune sainzi yekugadzirwa kwemagetsi.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesaMutauro weLua unowanzoshandiswa munzvimbo dzakasiyana-siyana. Inogona kuuya inobatsira:

  1. Mushandisi anotamba mitambo yemakomputa (nyora maplugins).
  2. Nyanzvi yekuvandudza mutambo (gadzira injini).
  3. Anwendung budiriro programmer (nyora plugins kune zvakasiyana-siyana zvinoshandiswa).
  4. Developer munzira yekumisikidzwa (mutauro haunonoke maitiro uye unobvumidza kuti ushande nemazvo)
  5. Vatengesi vekunyora zvinyorwa uye kutengesa bots. Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesa

Kutenda kuna Lua, anopfuura rimwe robhoti rekutengesa rakagadzirwa. Zvakanakira ndezvekuti mushandisi wega wega anogona kukurumidza kunzwisisa nuances yemutauro uye akazvimiririra kugadzira chirongwa chakadaro. Kuburikidza nazvo, zvinogoneka kutumira mirairo
kuQuik terminal uye kuita ongororo yehunyanzvi. Mutauro weLua ndewei, mhedziso yemutauro weLUA programming: https://youtu.be/PbYf6uNZFCE

Ipfupi nhoroondo data

Lua yakagadzirwa muna 1993 neBrazilian programmers kubva kuTecgraf division. Vagadziri vakave nechokwadi chekuti mushandisi wega wega aikwanisa kugadzirisa zvimwe zvekuvandudza mutauro. Izvi zvinogona kuitwa kuburikidza nekupinda pachena kune code. KuBrazil, kubuda kwemutauro wayo wekuronga kwaive kuwanikwa chaiko. Zvechokwadi, zvisati zvaitika, nyika ino haina kuwana kubudirira kwakadaro mumunda wekugadzirwa kwekombiyuta.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesaMutauro wakagadzirwa pahwaro hweSOL neDEL. Zviitiko izvi zvakaona nyika gore rakapfuura kupfuura Lua. Sangano rimwe chete reBrazil rakaita semunyori. Iyi mitauro yemapurogiramu yakatumirwa nePetrobras, kambani yehurumende imwe chete inobata mukugadzira nekugadzirisa mafuta. Iyo yazvino vhezheni yeLua 5.4.0 yakaburitswa nguva pfupi yadarika – muna 2020. Vagadziri vanoedza kuunza zvinonakidza uye zvinobatsira maficha mupurojekiti kakawanda sezvinobvira. Naizvozvo, chirongwa ichi chinogara chichivandudzwa uye chiri kudiwa pakati pevagadziri.

Zvimiro zveLua programming mutauro

Kutarisana neLua, mugadziri anopiwa mukana wekushandisa mutauro uyu, zvose zvakavakwa-mukati (nekuda kwekuti yakanyorwa) uye yakamira (mune dzimwe nguva, inogona kushandiswa pasina ma-add-ons). Apo vanyori vakashanda pakusikwa kweLua, vakaenda nemaune kunogadzira chigadziro chekushanda chisingatore nzvimbo yakawanda uye chichashanda nyore pane chero chinhu.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesaVagadziri vakaedza kurerutsa mutauro uyu nepavaigona napo, kuitira kuti kunyangwe vanogadzira mapurogiramu vagone kukurumidza kuuziva. Uku ndiko kuwedzera kudiwa kweprojekiti. Nyanzvi dzine mukana wekunyora kodhi uye kugadzira hukuru-hukuru budiriro pasina kushandisa maraibhurari pawebhusaiti yepamutemo. Vanyori vakatarisira kuwanikwa kwezviyero zvinodiwa mupurogiramu yacho pachayo. Vashandisi veNovice vanowanzo dzidza munzvimbo dzipi mutauro weLua unoshandiswa. Yakagadzirirwa kugadzirwa kwezvirongwa muindasitiri yeindasitiri. Asi nhasi, nerubatsiro rwemutauro uyu, marobhoti akasiyana-siyana ekutengesa, zvinyorwa, mitambo yemakomputa, maapplication, bots yeTeregiramu, nezvimwe zvakadaro zvinogadzirwa. Mukuwedzera, Lua inobatanidzwa mune imwe nzira itsva inobatsira kuongorora nzvimbo. Inoshandiswawo mukudzidzisa vadzidzi kumayunivhesiti. Mutauro unonyanya kufarirwa wechirongwa Lua unoonekwa kumba. Iri muBrazil iyo inoshandiswa pese pese (pazvinogoneka).

Zvakanakira nezvayakaipira

Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesaKufanana nechero chirongwa, iyo meshini uye chirongwa chemutauro weLua chine huwandu hwezvakanakira uye zvazvakaipira. Izvo zvakakosha kutanga neakanaka maficha ebudiriro:

  1. Kufambiswa kwemhando yepamusoro . Kusiyana nemapurogiramu mazhinji, Lua iri nyore kutamisa kubva kune imwe inoshanda sisitimu kuenda kune imwe. Muchiitiko ichi, hapana kuchinja kukuru. Chero zvazvingava, hapazovi nezvikanganiso mukodhi.
  2. Maraibhurari akawanda . Kuenzaniswa neJavaScript , Lua ine mashoma mashoma eraibhurari sarudzo. Nekudaro, iyo yepamutemo sosi ine zvese zvaunoda kuti ushande zvizere nemutauro.
  3. Kubudirira . Iyo sisitimu inobvumidza iwe kuwedzera iwo maraibhurari ayo akakosha kune imwe nzira yekukodha munguva pfupi.
  4. Kusununguka kwekushandisa . Programming gurus inongoda kudzidza zvishoma zvinyorwa zvemutauro, uye kunyangwe ipapo vanogona kuishandisa zvakachengeteka mukuvandudza kwavo. Kune avo vachangotanga nehurongwa, hazvitore nguva kuti unzwisise Lua zvakare.
  5. Kuchengetedza ndangariro kwakawanda . Nekugadzira zvirongwa mumutauro uyu, nyanzvi inovimbiswa kuona mutsauko nemamwe analogues. Mushure mezvose, budiriro yeLua inoda ndangariro shoma pane mudziyo.

Chinhu chimwe chete chakakanganisika pamutauro ndechekuti wakanyorwa. Uye izvi zvinoreva kuti kazhinji inogona kushandiswa pamwe chete nemimwe mitauro yekusimudzira. Inonyanya kufarirwa pane idzi ndiC. Ndiko kuti, iwe uchafanirwa kudzidza mumwe mutauro wepurogiramu.

Kuenzanisa neJavascript

Vazhinji vashandisi vanofananidza Lua neJavaScript, vachiti macode avo anenge akafanana. Zvechokwadi kune kufanana kwakawanda pakati pemitauro pane kusiyana. Asi, pasinei nokufanana kuri pachena, kune misiyano yakawanda. Semuenzaniso, Lua ine software yayo yekutsigira. Zvisinei, vagadziri veJavaScript munguva pfupi yapfuura vakaunza shanduro, maererano nazvo, mushandisi anongoda kunyora shoko rokuti “goho” pakati pemajenareta, mushure mokunge purogiramu ichatsigirwa.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesaIyo Lua opareta yekusimudza kune simba inoreva chiratidzo chakadaro “^”, nepo muJavaScript iri “**”. Iyo yekupedzisira ine zoom mukati uye zoom kunze mabasa. Asi Lua inogona kuita opareta yakawandisa. JavaScript ine mabasa akasiyana-siyana chete, nepo Lua achivatsanangura. JavaScript inogona kuzvirumbidza nekutsigira inozivikanwa Unicode standard. Mubatanidzwa “!==” unoshandiswa kuratidza kusaenzana mumutauro, uye Lua anoshandisa “~=” nokuda kwechinangwa chimwe chete. Mimwe misiyano inoratidzwa mutafura.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesa

Zvimiro zvekugadzira marobhoti ekutengesa mumutauro weLua

Kugadzira marobhoti paQLua hakuna kuoma zvachose, kunyangwe vanotanga vanogona kuzvibata. Chinhu chikuru ndechokunzwisisa dzidziso yekutanga pakutanga. Kuti unyore kodhi, iyo yakapfava mavara edhita inobatsira. Chirongwa chekugadzira chakafanana nekuumbwa kwechiratidzo. Zvisinei, pane musiyano usingakoshi mukodhi yacho pachayo. Imwe yakanaka “inosimudzira” – irobhoti richangoburwa rinogona kuiswa chero paPC yako.

Zvakakosha! Panofanira kuva nebasa rimwe chete mukodhi – “main”.

Kana iyo robhoti kodhi yaunganidzwa uye yagadziriswa, zvinokurudzirwa kuichengeta. Usakanganwa nezve lua extension. Sezvatotaurwa, purogiramu inogona kuiswa chero kupi zvako pakombuta. Kuti uedze kodhi yako, unofanirwa kumhanya robhoti. Kuti uite izvi, enda kuchikamu che “Services”. Pazasi pachava nemutsara “Lua scripts”, inofanira kudzvanywa.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesaZvadaro, hwindo rine zvinyorwa zvakatakurwa richaonekwa. Ikoko iwe unofanirwa kusarudza faira inodiwa uye kuimhanyisa uchishandisa bhatani rakakodzera.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesaPakupedzisira, zvinokurudzirwa kutarisa bot code yezvikanganiso. Kana zvose zvakanaka, robhoti inotanga. Muchiitiko chekurova, zvakakodzera kudzokera kune kodhi zvakare uye nekutarisa kwayo kurongeka.

Mhedziso yeakanakisa kutengesa marobhoti paLua – yakagadzirira-yakagadzirwa mhinduro kune vanotanga

Uchishandisa mutauro weLua programming, unogona kugadzira akasiyana marobhoti emhando ipi neipi yakaoma. Nekudaro, iwe unogona kutenga yakagadzirira-yakagadzirwa chirongwa. Inokurudzirwa kujairana neanozivikanwa algorithms akatogadzirira basa. Unogona kuzvitenga kana kuyedza demo vhezheni. Zadzisa robhoti yekutengesa yeQUIK terminal muLua: https://youtu.be/Z2xzOfNZFso

Robhoti-terminal “Delta Pro”

Inokutendera kuti uite 120 chero sarudzo papuratifomu imwe. Muchiitiko ichi, unogona kushandisa marudzi akasiyana-siyana ezvirongwa uye zvishandiso.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesa

RQ: Imwe muzana

Iyo robhoti yakagadzirirwa kutengesa mumunda wekutengesa. Iyo algorithm inokutendera iwe kuti uwedzere mari kubva pane ichi chiitiko kakawanda. Njodzi dzinoderedzwa, dzinogona kuverengwa nyore nyore.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesa

RQ: Martin

Iyo sisitimu inobvumidza iwe kuverenga iyo mijenya usati waita chibvumirano. Kutengeserana mu “semi-otomatiki” modhi inopihwa. Matanho anogona kuteverwa zvakabudirira uye kusetwa nemaoko.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesa

Mhando dzeLua zvinyorwa zveQUIK terminal

Paunenge uchiita rimwe basa mune QUIK terminal, zvinotevera zvinyorwa zvinoshandiswa:

  1. Lua zvinyorwa . Ivo vanogona kuchengetwa panetiweki, pane dhisiki yemunharaunda, kana mune imwe nzvimbo iyo ivo vanozosvika kune iyo terminal. Ivo vanoshanda zvakakwana kugadzira robhoti yekutengesa nerubatsiro rwavo. Izvo zvinogoneka kugadzira matafura muQUIK, shandisa maturusi sarudzo, kupa mirairo yekuita mabasa akasiyana, zvichingodaro.
  2. Custom zviratidzo . Pano, zvichienzaniswa nemaonero apfuura, zvishoma kushanda. Iyo purogiramu inoitirwa kuti mushandisi aratidze algorithm yezviito pane terminal machati.

Kuronga muLua kune avo vanoda kunyatsogona mutauro – dhawunirodha gwara rakazara:
Kuronga muLua Robots muLua yeQUIK – Iceberg robhoti: https://youtu.be/cxXwF_xmTHY

Maitiro ekunyora robhoti muLua

Sezvo afunga kugadzira rake robhoti, mushandisi anofanira kutevedzera pre-yakaunganidzwa algorithm. Paanowana ruzivo mukuronga, anozokwanisa kunyora nyore makodhi ake uye kuyedza. Nekusarudza Lua kuti adzidze nzvimbo iyi, anotanga haazokanganisi. Mushure mezvose, pakutanga, chinhu chikuru ndechokumira pamutauro wakapfava uye unonzwisisika. Kuti utange, vhura iyo QUIK yekutengesa terminal chirongwa. Muhwindo rayo, unofanirwa kugadzira folda. Iyi ndiyo nzvimbo ichachengeterwa zvese zvinyorwa zvakanyorwa. Mushandisi anogona kupa iyo folda zvachose chero zita, asi inofanirwa kunge ine mavara echiLatin chete. Ngatitii zita rayo ndi “LuaScripts”. Tevere, iwe unofanirwa kumisa iyo folda uye kugadzira chinyorwa chekunyora ipapo, semuenzaniso, Notepad. Munzvimbo isina chinhu (mukati mehwindo rechirongwa) unofanirwa kudzvanya-kurudyi
. Bhokisi rebhokisi richaonekwa, mune urongwa hwaunoda kusarudza “Gadzira” tab, uye ipapo “Text Document” mutsara.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesaInofanirawo kupiwa zita, kuitira kuti irege kuzovhiringidzika gare gare. Semuenzaniso, unogona kunyora “Script_N1”. Usakanganwa nezvekugadzirisa kwemutauro wakashandiswa – .lua. Ndiko kuti, mushandisi anofanira kuwana chinyorwa chakadaro pagwaro “Script_N1.lua”. Zvakadaro, Windows inowanzo chinja edzedzero otomatiki nekuisa .txt faira. Muchiitiko ichi, zvinokurudzirwa kugadzira gwaro muNotePad ++, kuisa sarudzo inodiwa. Muchirongwa ichi, iwe uchafanirwa kusarudza chikamu che “Syntaxes”. Bhokisi renhaurirano rine sarudzo dzakawanda richaonekwa pano. Iwe unofanirwa kusarudza “L”. Kubva ipapo, rimwe hwindo richaonekwa kwaunoda kudzvanya pa “Lua”.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesaMushure meizvozvo, mune imwecheteyo menyu, pamwe ne “Syntaxes” chikamu, unofanirwa kudzvanya pane “Faira” chikamu. Muhwindo rinotevera pachava nekunyorwa – “Save as”. Mushandisi anofanira kudzvanya pairi uye kumirira kusvika hwindo idzva ravhurika.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesaIkoko, kumusoro, mutsetse une zita rekare rakagadzirwa folda “Lua scripts” richaonekwa. Pazasi pehwindo, mamwe magwaro maviri akagadzirwa nemushandisi anoratidzwa. Kana zvese zvichienderana, iwe unofanirwa kusimbisa chiito uye chengetedza iyo yazvino mamiriro ekodhi.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesaNhanho inotevera ndeyekunyora kodhi mumutauro wakasarudzwa weLua programming. Vatangi vekutanga vanogona kushandisa murayiridzo, zvichabatsira kugadzira kodhi iri nyore, kuitira kuti nyanzvi iedze ruoko rwake. Iyo algorithm yezviito iri muchirongwa faira inonzi QLUA.chm. Zvinokurudzirwa, semuenzaniso, kunyora kodhi yakadaro isingaremi:
function main()
message(“Chinyorwa changu chekutanga chatangwa”);
end Next, iwe unofanirwa kudzvanya bhatani rekuchengetedza mune menyu.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesaIko code inofanira kuchengetwa mufaira “Script_N1.lua”. Isu tinoivhura uye tinoona kuti iyo debut script inoratidzwa sei. Kuti uivhure muQUIK, unofanirwa kuvhura chirongwa ichi uye sarudza iyo “Services” tab muchikamu chesarudzo. Tevere, bhokisi renhaurirano richaonekwa, ipapo iwe unofanirwa kudzvanya pa “LUA zvinyorwa …”.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesaIpapo mushandisi achaona iyo folda “Available scripts”. Pamusoro pekurudyi pane Wedzera bhatani. Dzvanya iyo uye tsvaga iyo faira ine kodhi. Inowanikwa pano “Script_N1.lua”.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesaPaunenge uchizarura gwaro, zvakakosha kusarudza mutsara “Script_N1.lua” (inofanira kuchengetwa pamotokari C), ipapo, pasi, chengetedza bhatani re “Run”.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesaHwindo idzva richabva raonekwa.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesaKuti udzivise aya asinganzwisisi mavara, unofanirwa kuenda kuchirongwa cheNotePad. Muzvirongwa pane chikamu “Encodings”, tinya pairi. Ipapo rondedzero yematabo ichaonekwa, pakati payo yaunofanira kudzvanya pa “Shandura ku ANSI”.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesaTevere, iwe unofanirwa kudzvanya bhatani rekuchengetedza uye wodzokera kuhwindo remeseji. Pachange patova nechimwe chinyorwa, uye kwete mutsara une zvinyorwa.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesa

Maitiro ekuronga muLUA muQUIK terminal

Pane 3 nzira dzakakurumbira:

  1. Chero faira remavara rakagadzirwa, uko .lua extension inofanira kuiswa. Tevere, iwe unofanirwa kuvhura mupepeti uye kunyora kodhi. Mushure mekutanga, algorithm yakadaro ichaitwa kamwe chete. Iwe unogona kuimhanyisa nemaoko nekusingaperi. Iwe unogona kuishandisa kune imwe-nguva kuverenga yerumwe ruzivo.
  2. Mune Lua script pachayo, unofanirwa kugadzira basa rinonzi  main() . Uyezve, mubasa rimwechete, unoda kuisa kodhi yakanyorwa. Uye iyo sleep() basa  rinobatsira kumbomira script kana, neimwe nzira, tangazve. Ndokunge, kana iwe ukamisa iyo huru () basa, uye wozoisa iyo yekurara () basa, iwe unozogona kuwana kuverenga ne frequency yenguva yakatarwa.
  3. Muchirongwa cheQLUA, unogona kushandisa iyo inofambiswa nechiitiko chekusimudzira modhi. Nokudaro, ikozvino hazvidikanwi “kuona” kuchinja mune rimwe basa uye, nekuda kweizvi, ita mirairo inotevera.

Inokurudzirwa kuongorora nzira yekupedzisira mune zvakadzama. Kuti ubate chimwe chiitiko, iwe unofanirwa kunyora basa mune script muKurumidza. Unogona kushandisa chirongwa chinotevera: Chinyorwa
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesacheLUA chinogona kuve neanoverengeka mabasa ane akakosha mazita: dhiri, makotesheni, zvichingodaro. Iwe unofanirwa kuwana chikamu che “Tables” purogiramu, enda ku “Lua”. Bhokisi rebhokisi richaonekwa ipapo uye mutsara we “Available scripts” uchaonekwa, tinya pairi. Tevere, tinya pane “Launch” tab. Ipapo kunouya kugadzirisa uye kuuraya iyo inosungirwa
main() basa . Zvadaro, iwe unofanirwa kuzivisa 
is_run , basa racho rinenge riine kukosha 
kwechokwadikusvikira mushandisi aita bhatani reStop Script. Zvadaro shanduko yebasa inoenda mune yenhema modhi mukati meOnStop (). Mushure meizvozvo, iyo main () basa rinopera, uye script pachayo inomira. Chinyorwa chakanyorwa chinofanira kuchengetwa uye kumhanya. Paunenge uchiita kutengeserana, mushandisi achaona iyo data yejeti yega yega uye huwandu hwekupedzisira hwekutengesa.
Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesaKuti umhanye QLua nekukasira, unofanirwa kuiendesa kune folda nyowani paPC yako. Iwe unogona kuidana chero chaunoda, semuenzaniso, “MyLua”. Zvese zvinyorwa zveLua zvichachengetwa ipapo. Kana wapinda QUIK, unofanirwa kuvhura chikamu che “Services”, wobva wadzvanya pa “Lua scripts” tab. Muhwindo rinovhurwa, shandisa bhatani re “Wedzera”. Ipapo iwe unofanirwa kusarudza script uye kuivhura. Ichange iri muchikamu che “Downloaded Scripts”. Ipapo iwe unofanirwa kuratidza mutsara wechinyorwa uye tinya “Mhanya”. Kuti umise script, ingobaya “Misa”. Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesa

Maitiro ekuisa LUA script mune yekutengesa terminal

Iwo kudzidziswa uye akajairwa zviteshi zvinoda algorithm yakafanana yekuisa robhoti yekutengesa:

  1. Izvo zvinodikanwa kudzvanya pane “Services” chikamu mune yepamusoro menyu yeiyo terminal.
  2. Tevere, tsvaga bhatani re “LUA zvinyorwa” mubhokisi rekudonha-pasi uye tinya:Lua programming, kutengesa marobhoti uye zvinyorwa zvekutengesa
  3. Panguva iyoyo, hwindo re “Available Scripts” rinofanira kuoneka. Zvadaro, iwe unofanirwa kumisa bhatani re “Wedzera” uye wosarudza faira reirobhoti rinodiwa rekutengesa.

Kutora data kubva kuchati yeLua ine script muQuik terminal: https://youtu.be/XVCZAnWoA8E Lua isarudzo huru yekudzidza kuronga uye kubudirira mune ramangwana. Chinhu chikuru hachisi chekumira chete pakuverenga dzidziso. Zviri nani kudzidza zvinyorwa nekugara uchidzidzira. Mushure meimwe nguva, mugadziri anotanga kufambira mberi uye anokwanisa kugadzira yake yakakosha chigadzirwa.

info
Rate author
Add a comment