Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsa

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

Pogwiritsa ntchito chilankhulo cha Lua, mutha kupanga masewera osiyanasiyana, zofunikira,
maloboti ogulitsa ndi zina. Chilankhulo cha Lua ndi chosavuta kumva, chili ndi womasulira wotchuka. Akufuna kudziwana ndi Lua pafupi, komanso kuphunzira kulemba loboti yamalonda kapena zolemba m’chinenerochi.

Kodi chinenero cha Lua n’chiyani ndipo n’chothandiza bwanji?

Lua ndi chilankhulo chosavuta kugwiritsa ntchito. Oyamba amavomereza kuti ndi chithandizo chake, mutha kuphunzira zoyambira zamapulogalamu munthawi yochepa. Lua amaphatikizidwa bwino ndi zochitika zomwe zidapangidwa m’chinenero china. Nthawi zambiri amalimbikitsidwa kwa ophunzira omwe angoyamba kumene mu sayansi yamagetsi.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaChilankhulo cha Lua chimagwiritsidwa ntchito m’magawo osiyanasiyana. Zingakhale zothandiza:

  1. Wogwiritsa amene amasewera masewera apakompyuta (lembani mapulagini).
  2. Katswiri wopanga masewera (kupanga injini).
  3. Pulogalamu yopititsa patsogolo ntchito (lembani mapulagini azinthu zosiyanasiyana).
  4. Madivelopa panjira yophatikizidwa (chinenerocho sichimachedwetsa ndondomekoyi ndikukulolani kuti mugwire ntchito bwino)
  5. Ochita malonda polemba zolemba ndi malonda bots. [id id mawu = “attach_13245” align = “aligncenter” wide = “805”] Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaLoboti yogulitsa ya QUIK pa Lua pogulanso milingo[/caption]

Chifukwa cha Lua, maloboti opitilira malonda amodzi apangidwa. Ubwino wake ndikuti wogwiritsa ntchito aliyense amatha kumvetsetsa zovuta za chilankhulocho ndikudzipangira yekha pulogalamu yotere. Kudzera mu izi, zitha kutumiza malamulo ku
terminal ya Quik ndikuchita kusanthula kwaukadaulo. Kodi chilankhulo cha Lua ndi chiyani, mwachidule chilankhulo cha pulogalamu ya LUA: https://youtu.be/PbYf6uNZFCE

Zambiri zakale

Lua idapangidwa mu 1993 ndi opanga mapulogalamu aku Brazil ochokera kugawo la Tecgraf. Madivelopa anaonetsetsa kuti wosuta aliyense akhoza kusintha zina kuti chitukuko cha chinenero. Izi zitha kuchitika kudzera potsegula ma code. Kwa Brazil, kutulukira kwa chinenero chake cha mapulogalamu kunali kutulukira kwenikweni. Zowonadi, izi zisanachitike, dziko lino silinapindule bwino pankhani ya chitukuko cha makompyuta.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaChilankhulocho chinapangidwa pamaziko a SOL ndi DEL. Zochitika izi zidawona dziko lapansi chaka cham’mbuyo kuposa Lua. Bungwe lomwelo la ku Brazil lidachita monga wolemba. Zilankhulo zamapulogalamu izi zidatumizidwa ndi Petrobras, kampani yadziko lomwelo yomwe imagwira ntchito yopanga ndi kukonza mafuta. Mtundu waposachedwa wa Lua 5.4.0 udatulutsidwa posachedwa – mu 2020. Madivelopa amayesa kuyambitsa zinthu zosangalatsa komanso zothandiza pantchitoyi pafupipafupi momwe angathere. Chifukwa chake, pulogalamuyi imasinthidwa pafupipafupi ndipo ikufunika pakati paopanga.

Mawonekedwe a chilankhulo cha Lua

Poyang’anizana ndi Lua, wopanga mapulogalamuwa amapatsidwa mwayi wogwiritsa ntchito chinenerochi, zonse zomangidwa (chifukwa chakuti zimalembedwa) ndi zoyima (nthawi zina, zingagwiritsidwe ntchito popanda zowonjezera). Pamene olemba adagwira ntchito yopanga Lua, adapita mwadala kuti apange chida chogwiritsira ntchito chomwe sichitenga malo ambiri ndipo chidzagwira ntchito mosavuta pa chipangizo chilichonse.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaMadivelopa anayesa kufewetsa chilankhulochi momwe angathere, kotero kuti ngakhale opanga mapulogalamu a novice amatha kuchidziwa mwachangu. Uku ndiye kuchuluka kwa kufunikira kwa polojekitiyi. Akatswiri ali ndi mwayi wolembera ma code ndikupanga chitukuko chachikulu popanda kugwiritsa ntchito malaibulale patsamba lovomerezeka. Olembawo adasamalira kupezeka kwa magawo ofunikira mu pulogalamu yokha. Ogwiritsa ntchito atsopano amakonda kuphunzira m’malo omwe chilankhulo cha Lua chimagwiritsidwa ntchito. Anapangidwa kuti apange mapulogalamu mu gawo la mafakitale. Koma lero, mothandizidwa ndi chinenerochi, ma robot osiyanasiyana ogulitsa malonda, zolemba, masewera apakompyuta, mapulogalamu, bots a Telegram, ndi zina zotero. Kuphatikiza apo, Lua akutenga nawo gawo munjira yatsopano yomwe imathandiza kufufuza malo. Amagwiritsidwanso ntchito pophunzitsa ophunzira ku mayunivesite. Chilankhulo chodziwika bwino cha pulogalamu ya Lua chimaganiziridwa kunyumba. Ndi ku Brazil komwe amagwiritsidwa ntchito pafupifupi kulikonse (ngati kuli kotheka).

Ubwino ndi kuipa kwake

Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaMonga pulogalamu iliyonse, makina ndi chilankhulo cha Lua chili ndi zabwino ndi zoyipa zake. Ndikoyenera kuyamba ndi mbali zabwino zachitukuko:

  1. Mayendedwe abwino . Mosiyana ndi mapulogalamu ambiri, Lua ndi yosavuta kusamutsa kuchokera ku opaleshoni ina kupita ku ina. Pankhaniyi, palibe kusintha kwakukulu. Mulimonsemo, sipadzakhala zolakwika mu code.
  2. Malaibulale ambiri . Poyerekeza ndi JavaScript , Lua ili ndi njira zochepa zama library. Komabe, gwero lovomerezeka lili ndi zonse zomwe mungafune kuti mugwiritse ntchito chilankhulocho.
  3. Kuchita bwino . Dongosolo limakupatsani mwayi wowonjezera ma library omwe ali ofunikira panjira inayake yolembera munthawi yochepa.
  4. Kusavuta kugwiritsa ntchito . Akatswiri opanga mapulogalamu amangofunika kuphunzira pang’ono za chilankhulocho, ndipo ngakhale atatero amatha kuchigwiritsa ntchito bwino pakukula kwawo. Kwa iwo omwe angoyamba kumene ndi mapulogalamu, sizitenga nthawi kuti amvetsetse Lua mwina.
  5. Kusungirako kukumbukira kwakukulu . Popanga mapulogalamu m’chinenerochi, katswiri amatsimikiziridwa kuti awona kusiyana ndi ma analogi ena. Kupatula apo, chitukuko cha Lua chimafunikira kukumbukira pang’ono pazida.

Vuto lalikulu la chinenerocho ndi lolembedwa. Ndipo izi zikutanthauza kuti nthawi zambiri amatha kugwiritsidwa ntchito limodzi ndi zilankhulo zina zachitukuko. Chodziwika kwambiri mwa izi ndi C. Ndiko kuti, muyenera kuphunzira chinenero chowonjezera cha mapulogalamu.

Kufananiza ndi Javascript

Ogwiritsa ntchito ambiri amayerekezera Lua ndi JavaScript, ponena kuti ma code awo ndi ofanana. Pali kufanana kwambiri pakati pa zilankhulo kuposa kusiyana. Koma, mosasamala kanthu za kufanana koonekeratu, pali zosiyana zambiri. Mwachitsanzo, Lua ili ndi pulogalamu yake yothandizira. Komabe, opanga JavaScript posachedwapa adayambitsa zosintha, malinga ndi zomwe, wogwiritsa ntchito amangofunika kulemba mawu akuti “zokolola” pakati pa jenereta, pambuyo pake pulogalamuyo idzathandizidwa.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaWogwiritsa ntchito Lua pokweza mphamvu amatanthauza chizindikiro “^”, pomwe mu JavaScript ndi “**”. Yotsirizirayi ili ndi zoom ndi zoom kunja. Koma Lua amatha kudzaza opareshoni. JavaScript imakhala ndi ntchito zosinthika zokha, pomwe Lua adazifotokozera. JavaScript imatha kudzitama kuti imathandizira mulingo wodziwika bwino wa Unicode. Kuphatikizika “!==” kumagwiritsidwa ntchito kusonyeza kusalingana m’chinenerocho, ndipo Lua amagwiritsa ntchito “~=” pa cholinga chomwecho. Kusiyana kwina kukuwonetsedwa mu tebulo.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsa

Mawonekedwe a maloboti opangira malonda muchilankhulo cha Lua

Kupanga ma robot pa QLua sikovuta konse, ngakhale oyamba kumene atha kukwanitsa. Chinthu chachikulu ndikumvetsetsa chiphunzitso choyambirira pachiyambi. Kuti mupange kachidindo, cholembera chosavuta kwambiri chimakhala chothandiza. Chiwembu chopanga chimafanana ndi kuphatikiza kwa chizindikiro. Komabe, pali kusiyana kochepa mu code yokha. “Kuwunikira” kwina kwabwino – loboti yopangidwa kumene ikhoza kuyikidwa paliponse pa PC yanu.

Zofunika! Payenera kukhala ntchito imodzi yokha mu code – “main”.

Khodi ya robot ikapangidwa ndikusinthidwa, tikulimbikitsidwa kuti musunge. Musaiwale za kukula kwa lua. Monga tanenera kale, pulogalamuyi ikhoza kuikidwa paliponse pa kompyuta. Kuti muyese khodi yanu, muyenera kuyendetsa loboti. Kuti muchite izi, pitani ku gawo la “Services”. Pansi padzakhala mzere “Lua scripts”, uyenera kudina.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaKenako, zenera lomwe lili ndi zolemba zodzaza lidzawonekera. Pamenepo muyenera kusankha fayilo yofunikira ndikuyiyendetsa pogwiritsa ntchito batani loyenera.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaPamapeto pake, tikulimbikitsidwa kuyang’ana nambala ya bot kuti muwone zolakwika. Ngati zonse zili bwino, robot imayamba. Pakakhala kugunda, ndikofunikira kubwereranso ku code ndikuwunika kulondola kwake.

Chidule cha maloboti abwino kwambiri ogulitsa pa Lua – mayankho okonzeka oyambira

Pogwiritsa ntchito chilankhulo cha Lua, mutha kupanga mitundu yosiyanasiyana ya maloboti azovuta zilizonse. Komabe, mutha kugula pulogalamu yopangidwa kale. Akufunsidwa kuti adziŵe ma aligorivimu odziwika omwe ali okonzeka kale kugwira ntchito. Mutha kuzigula kapena kuyesa mtundu wawonetsero. Loboti yathunthu yogulitsa malo a QUIK ku Lua: https://youtu.be/Z2xzOfNZFso

Maloboti “Delta Pro”

Imakulolani kuyambitsa pafupifupi 120 zosankha zilizonse papulatifomu imodzi. Pankhaniyi, mungagwiritse ntchito njira zosiyanasiyana ndi zida.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsa

RQ: Peresenti imodzi

Robotiyi idapangidwa kuti izichita malonda pazamalonda. Algorithm imakulolani kuti muwonjezere ndalama kuchokera ku ntchitoyi kangapo. Zowopsa zimachepetsedwa, zimatha kuwerengedwa mosavuta.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsa

RQ: Martin

Dongosolo limakupatsani mwayi wowerengera zambiri musanapange mgwirizano. Kugulitsa mu “semi-automatic” mode kumaperekedwa. Miyezo imatha kutsatiridwa bwino ndikukhazikitsidwa pamanja.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsa

Mitundu ya zilembo za Lua za terminal ya QUIK

Mukamagwira ntchito inayake mu terminal ya QUIK, zolemba zotsatirazi zimagwiritsidwa ntchito:

  1. Lua scripts . Atha kusungidwa pa netiweki, pa disk yakomweko, kapena kumalo ena komwe angapezeke ndi terminal. Amagwira ntchito mokwanira kuti apange loboti yogulitsa ndi thandizo lawo. Zidzakhala zotheka kupanga matebulo mu QUIK, kugwiritsa ntchito zosankha za zida, kupereka malamulo oti mugwire ntchito zosiyanasiyana, ndi zina zotero.
  2. Zizindikiro zachizolowezi . Apa, poyerekeza ndi m’mbuyomu view, mochepa magwiridwe antchito. Pulogalamuyi idapangidwa kuti wogwiritsa ntchito awonetse ma algorithm a zochita pa ma chart chart.

Kukonzekera mu Lua kwa iwo omwe akufuna kudziwa bwino chilankhulo – tsitsani malangizo athunthu:
Kupanga Mapulogalamu mu Lua Robots ku Lua kwa QUIK – Loboti ya Iceberg: https://youtu.be/cxXwF_xmTHY

Momwe mungalembe roboti ku Lua

Ataganiza zopanga loboti yake, wogwiritsa ntchitoyo ayenera kutsatira algorithm yopangidwa kale. Akapeza chidziwitso pakupanga mapulogalamu, azitha kulemba ma code ake mosavuta ndikuyesa. Posankha Lua kuti aphunzire derali, woyambitsa sadzalakwitsa. Kupatula apo, poyambira, chinthu chachikulu ndikuyimitsa chilankhulo chosavuta komanso chomveka bwino. Kuti muyambe, tsegulani pulogalamu yamalonda ya QUIK. Pazenera lake, muyenera kupanga chikwatu. Apa ndi pamene zolembedwa zonse zidzasungidwa. Wogwiritsa atha kupatsa chikwatu dzina lililonse, koma liyenera kukhala ndi zilembo zachilatini zokha. Tinene kuti dzina lake ndi “LuaScripts”. Kenako, muyenera yambitsa chikwatu ndikupanga cholembera pamenepo, mwachitsanzo, Notepad. Pamalo opanda kanthu (mkati mwa zenera la pulogalamu) muyenera dinani kumanja
. Bokosi la zokambirana lidzawoneka, pamndandanda womwe muyenera kusankha “Pangani” tabu, ndiyeno mzere wa “Text Document”.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaIyeneranso kupatsidwa dzina, kuti isasokonezedwe pambuyo pake. Mwachitsanzo, mukhoza kulemba “Script_N1”. Musaiwale za kusamvana kwa chinenero chogwiritsidwa ntchito – .lua. Ndiko kuti, wogwiritsa ntchito ayenera kupeza zolemba zoterezi pa chikalata “Script_N1.lua”. Komabe, Windows nthawi zambiri imasintha zowonjezerazo poyika fayilo ya .txt. Pankhaniyi, tikulimbikitsidwa kuti mupange chikalata mu NotePad ++, ndikukhazikitsa chisankho chofunikira. Mu pulogalamuyi, muyenera kusankha “Syntaxes” gawo. Bokosi la zokambirana lomwe lili ndi zosankha zingapo liwonekera apa. Muyenera kusankha “L”. Kumeneko, zenera lina adzaoneka kumene muyenera alemba pa “Lua”.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaPambuyo pake, mumenyu yomweyi, pamodzi ndi gawo la “Syntaxes”, muyenera kudina gawo la “Fayilo”. Pazenera lotsatira padzakhala zolembedwa – “Save as”. Wogwiritsa ntchito ayenera kudina ndikudikirira mpaka zenera latsopano litatsegulidwa.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaKumeneko, pamwamba, mzere wokhala ndi dzina la foda yomwe idapangidwa kale “Lua scripts” idzawonekera. Pansi pa zenera, 2 zolemba zina zomwe wosuta wapanga zikuwonetsedwa. Ngati zonse zikugwirizana, muyenera kutsimikizira zomwe zikuchitika ndikusunga momwe nambalayo ilili.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaChotsatira ndikulemba kachidindo m’chinenero chosankhidwa cha Lua. Oyamba kumene angagwiritse ntchito malangizowo, adzakuthandizani kupanga code yosavuta, kuti katswiri ayese dzanja lake. Algorithm ya zochita ili mu fayilo ya pulogalamu yotchedwa QLUA.chm. Mwachitsanzo, akufunsidwa kuti alembe nambala yopepuka ngati iyi:
function main()
message(“Zolemba zanga zoyamba zakhazikitsidwa”);
kumapeto Kenako, muyenera alemba pa kusunga batani mu menyu.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaKhodiyo iyenera kusungidwa mufayilo “Script_N1.lua”. Timayiyambitsa ndikuwona momwe script yoyamba imasonyezera. Kuti mutsegule mu QUIK, muyenera kutsegula pulogalamuyi ndikusankha tabu ya “Services” m’gawo la zosankha. Kenako, bokosi la zokambirana lidzawoneka, pamenepo muyenera kudina “LUA scripts …”.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaKenako wosuta adzawona chikwatu “Zolemba Zomwe zilipo”. Pamwamba kumanja pali Add batani. Dinani ndikuyang’ana fayilo yokhala ndi code. Ili pano “Script_N1.lua”.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaMukatsegula chikalata, ndikofunikira kusankha mzere “Script_N1.lua” (uyenera kusungidwa pagalimoto C), ndiye, pansi, dinani batani la “Thamangani”.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaA zenera latsopano yomweyo kuonekera.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaKuti mupewe zilembo zosamvetsetseka izi, muyenera kupita ku pulogalamu ya NotePad. Pazokonda pali gawo “Encodings”, dinani pamenepo. Kenako mndandanda wa ma tabo udzawonekera, pakati pawo muyenera dinani “Sinthani ku ANSI”.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaKenako, muyenera alemba pa kusunga batani ndi kubwerera ku uthenga zenera. Padzakhala kale zolembedwa zina, osati mzere wokhala ndi zolembera.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsa

Momwe mungapangire mu LUA mu QUIK terminal

Pali njira zitatu zodziwika bwino:

  1. Fayilo iliyonse yolemba imapangidwa, pomwe .lua yowonjezera iyenera kuikidwa. Kenako, muyenera kutsegula mkonzi ndi kulemba code. Pambuyo poyambira, algorithm yotereyi idzachitika kamodzi kokha. Mukhoza kuyendetsa pamanja mpaka kalekale. Mutha kugwiritsa ntchito kuwerengera kamodzi kwazinthu zina.
  2. Mu Lua script palokha, muyenera kupanga ntchito yotchedwa  main() . Komanso, mu ntchito yomweyi, muyenera kuyika code yolembedwa. Ndipo ntchito ya kugona () ndiyothandiza  kuyimitsa kwakanthawi script kapena, kuyambiranso. Ndiko kuti, ngati mutayambitsa ntchito yaikulu (), ndikuyika ntchito ya kugona (), mudzatha kukwaniritsa mawerengedwe ndi mafupipafupi a nthawi yeniyeni.
  3. Mu pulogalamu ya QLUA, mutha kugwiritsa ntchito njira yachitukuko yoyendetsedwa ndi zochitika. Choncho, tsopano sikoyenera “kuzindikira” kusintha kwa ntchito imodzi ndipo, chifukwa cha izi, perekani malamulo otsatirawa.

Akufunsidwa kusanthula njira yotsirizayi mwatsatanetsatane. Kuti muthane ndi chochitika china, muyenera kulemba ntchito mu script mu Quick. Mutha kugwiritsa ntchito chiwembu chotsatirachi: Zolemba
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaza LUA zitha kukhala ndi ntchito zingapo zokhala ndi mayina apadera: deal, quotes, ndi zina. Muyenera kupeza “Matebulo” gawo mu pulogalamu, kupita “Lua”. Bokosi la zokambirana lidzawonekera pamenepo ndipo mzere “Zolemba zomwe zilipo” zidzawoneka, dinani pamenepo. Kenako, alemba pa “Launch” tabu. Kenako pamabwera kukonza ndi kuchitidwa kwa ntchito yofunikira
() . Kenako, muyenera kulengeza 
is_run , ntchitoyi idzakhala ndi mtengo 
wowonampaka wosuta atsegula batani la Stop Script. Kenako kusinthika kwa ntchito kumapita munjira zabodza mkati mwa OnStop (). Pambuyo pake, main() ntchito imatha, ndipo script yokha imayima. Zolemba zolembedwa ziyenera kusungidwa ndikuyendetsedwa. Pochita malonda, wogwiritsa ntchito awona deta pagawo lililonse komanso kuchuluka komaliza kwa zomwe zachitika.
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaKuti muthamangitse QLua mwachangu, muyenera kusamutsa ku foda yatsopano pa PC yanu. Mutha kuyitcha chilichonse chomwe mungafune, mwachitsanzo, “MyLua”. Zolemba zonse za Lua zidzasungidwa pamenepo. Mukalowa QUIK, muyenera kutsegula gawo la “Services”, kenako dinani “Lua scripts”. Pazenera lomwe limatsegulira, yambitsani batani la “Add”. Kenako muyenera kusankha script ndikutsegula. Idzakhala mu gawo la “Downloaded Scripts”. Kenako muyenera kuwunikira mzere wa script ndikudina “Thamangani”. Kuti muyimitse script, ingodinani “Imani”. [id id mawu = “attach_1215” align = “aligncenter” wide = “1919”]
Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsaBot for Quik pa LUA[/caption]

Momwe mungayikitsire script ya LUA mu malo ogulitsa

Maphunziro ndi ma terminals okhazikika amafunikira ma algorithm omwewo pakuyika loboti yogulitsa:

  1. M’pofunika alemba pa “Services” gawo mu pamwamba menyu wa terminal.
  2. Kenako, pezani batani la “LUA scripts” mubokosi lotsitsa ndikudina:Lua mapulogalamu, maloboti ogulitsa ndi zolemba zogulitsa
  3. Panthawiyo, zenera la “Malemba Opezeka” liyenera kuwonekera. Kenako, muyenera yambitsa batani la “Add” ndikusankha fayilo ya loboti yofunikira.

Kutenga deta kuchokera ku tchati cha Lua chokhala ndi script mu Quik terminal: https://youtu.be/XVCZAnWoA8E Lua ndi njira yabwino yophunzirira mapulogalamu komanso kuchita bwino mtsogolo. Chinthu chachikulu sikuti mungosiya kuwerenga chiphunzitsocho. Ndi bwino kuphunzira nkhaniyo mwa kuyeserera nthawi zonse. Patapita nthawi, woyambitsayo ayamba kupita patsogolo ndikutha kupanga mankhwala ake opindulitsa.

info
Rate author
Add a comment