当前位置:网站首页>[Lua language from bronze to king] Part 2: development environment construction +3 editor usage examples
[Lua language from bronze to king] Part 2: development environment construction +3 editor usage examples
2022-06-24 07:38:00 【This is ah Mu】
Preface
In the last chapter, we introduced lua The past and this life , Although I don't see many friends , At same time, there is no recommendation and no traffic ; Most people don't think there is any nutrition , In fact, I personally don't think so :“ You like a language , Is it necessary to understand the origin of this language ; Why did the author create this language ? Which pain diseases have been solved ? Its own advantages and history ?”. At least through the translation of foreign languages to understand lua The past of language , I feel it is not easy along the way .
Java、Go、Python These popular languages are very popular , Of course! , I like them too . But I will also insist on using my spare time to record and practice about lua The article .
Lua The language supports the following systems
- Windows
- Linux
- Mac OS
linux Installation package download address :lua Development package download address
windows Installation package download address :windows Development package download address
Lua Use the officially recommended method :http://luadist.org/
Lua Development package installation
1、Mac On the computer
* Desktop mkdir luadir -- Create a... On the desktop lua Installation package folder
* Desktop cd luadir
* luadir curl -R -O http://www.lua.org/ftp/lua-5.4.3.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 349k 100 349k 0 0 35654 0 0:00:10 0:00:10 --:--:-- 48646
* luadir tar zxf lua-5.4.3.tar.gz
* luadir cd lua-5.4.3
* lua-5.4.3 make macosx test
/Library/Developer/CommandLineTools/usr/bin/make all SYSCFLAGS="-DLUA_USE_MACOSX -DLUA_USE_READLINE" SYSLIBS="-lreadline"
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o lapi.o lapi.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c lcode.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o lctype.o lctype.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o ldebug.o ldebug.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o ldo.o ldo.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o ldump.o ldump.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o lfunc.o lfunc.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o lgc.o lgc.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c llex.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o lmem.o lmem.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o lobject.o lobject.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o lopcodes.o lopcodes.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c lparser.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o lstate.o lstate.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o lstring.o lstring.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o ltable.o ltable.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o ltm.o ltm.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o lundump.o lundump.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o lvm.o lvm.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o lzio.o lzio.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o lauxlib.o lauxlib.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o lbaselib.o lbaselib.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o lcorolib.o lcorolib.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o ldblib.o ldblib.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o liolib.o liolib.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o lmathlib.o lmathlib.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o loadlib.o loadlib.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o loslib.o loslib.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o lstrlib.o lstrlib.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o ltablib.o ltablib.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o lutf8lib.o lutf8lib.c
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o linit.o linit.c
ar rcu liblua.a lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o lauxlib.o lbaselib.o lcorolib.o ldblib.o liolib.o lmathlib.o loadlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o linit.o
ranlib liblua.a
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o lua.o lua.c
gcc -std=gnu99 -o lua lua.o liblua.a -lm -lreadline
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_MACOSX -DLUA_USE_READLINE -c -o luac.o luac.c
gcc -std=gnu99 -o luac luac.o liblua.a -lm -lreadline
./lua -v
Lua 5.4.3 Copyright (C) 1994-2021 Lua.org, PUC-Rio ### install ok
### Use sudo Can only be
* lua-5.4.3 sudo make install
Password:
cd src && mkdir -p /usr/local/bin /usr/local/include /usr/local/lib /usr/local/man/man1 /usr/local/share/lua/5.4 /usr/local/lib/lua/5.4
cd src && install -p -m 0755 lua luac /usr/local/bin
cd src && install -p -m 0644 lua.h luaconf.h lualib.h lauxlib.h lua.hpp /usr/local/include
cd src && install -p -m 0644 liblua.a /usr/local/lib
cd doc && install -p -m 0644 lua.1 luac.1 /usr/local/man/man1
### After the installation is successful, let's check our lua Version number
* lua-5.4.3 lua -v
Lua 5.4.3 Copyright (C) 1994-2021 Lua.org, PUC-Rio
### Version number before installation
* ~ lua -v
Lua 5.3.5 Copyright (C) 1994-2018 Lua.org, PUC-Riomac The terminal can also be accessed through homebrew To install lua:
### The installation process is omitted here brew install lua
2、Linux Centos Install on the terminal
### View this machine lua edition [[email protected] ~]# lua -v Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio ### download lua The latest version of the installation package [[email protected] ~]# curl -R -O http://www.lua.org/ftp/lua-5.4.3.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 349k 100 349k 0 0 18443 0 0:00:19 0:00:19 --:--:-- 10397 ### Unzip the installation package [[email protected] ~]# tar zxf lua-5.4.3.tar.gz ### Switch to the installation package directory [[email protected] ~]# cd lua-5.4.3 ### Test the compilation results , It can detect the previous make Missing error in compilation step , Ensure that the compilation of the service is normal [[email protected] lua-5.4.3]# make linux test make[1]: Entering directory `/root/lua-5.4.3/src' make all SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl" make[2]: Entering directory `/root/lua-5.4.3/src' gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_LINUX -c -o lapi.o lapi.c gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_LINUX -c lcode.c gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_LINUX -c -o lctype.o lctype.c ........................... Omit the compilation process ................................................ gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_LINUX -c -o lua.o lua.c gcc -std=gnu99 -o lua lua.o liblua.a -lm -Wl,-E -ldl gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_LINUX -c -o luac.o luac.c gcc -std=gnu99 -o luac luac.o liblua.a -lm -Wl,-E -ldl make[2]: Leaving directory `/root/lua-5.4.3/src' make[1]: Leaving directory `/root/lua-5.4.3/src' make[1]: Entering directory `/root/lua-5.4.3/src' ./lua -v Lua 5.4.3 Copyright (C) 1994-2021 Lua.org, PUC-Rio ### compile ok make[1]: Leaving directory `/root/lua-5.4.3/src' ### install [[email protected] lua-5.4.3]# make install cd src && mkdir -p /usr/local/bin /usr/local/include /usr/local/lib /usr/local/man/man1 /usr/local/share/lua/5.4 /usr/local/lib/lua/5.4 cd src && install -p -m 0755 lua luac /usr/local/bin cd src && install -p -m 0644 lua.h luaconf.h lualib.h lauxlib.h lua.hpp /usr/local/include cd src && install -p -m 0644 liblua.a /usr/local/lib cd doc && install -p -m 0644 lua.1 luac.1 /usr/local/man/man1
If the following problems arise :
cd src && mkdir -p /usr/local/bin /usr/local/include /usr/local/lib /usr/local/man/man1 /usr/local/share/lua/5.4 /usr/local/lib/lua/5.4 mkdir: cannot create directory ‘/usr/local/man/man1’: File exists make: *** [install] Error 1 ## explain Obviously, it is not possible to create existing folders during installation , We can delete this existing folder Carry on make install
3、Window Installation on system Lua
① Go to github On :https://github.com/rjpcomputing/luaforwindows/releases Download the corresponding version of lua Installation package ② Unzip to D:\5.1 ③ Configure environment variables ( Look at the picture below ) ④ Input Windows+R —–> cmd —-> lua ⑤ Verify that the installation was successful ( Look at the picture below ) C:\Users\amumu>lua Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
Configure environment variables :
Configure environment variables
Verify that the installation was successful :
Verify that the installation was successful
Lua Language development editor selection
1、IDEA Editor tools ( With mac Computer as an example )
After successful installation , It is dark purple when opened :
idea Editor
LUA The code prompts the plug-in address :https://github.com/EmmyLua/IntelliJ-EmmyLua
2、VSCode Editor tools (Visual Studio Code)
Microsoft products , One runs on Mac OS、Windows and Linux Tools above , Powerful ,Lua There are countless language plug-ins , It can also support intelligent prompts , Compile, run and other functions .
Official download address :https://code.visualstudio.com/
After successful installation, you can choose to install plug-ins that you think are good :
Then write a quick lua Script running :
local tonumber = tonumber
-- Define a table Array
local _table = {' Hello everyone !', ' I am amu children's shoes !', ' You can search wechat official account :', ' I'm amu ', '; Friends can pay attention to me !'}
-- Loop iteration
local text = ''
for i,v in ipairs(_table) do
text = text..v
end
print(text) ### Hello everyone ! I am amu children's shoes ! You can search wechat official account : I'm amu ; Friends can pay attention to me !VSCode in “Terminal” -> New Terminal, perform lua hello.lua Command run directly hello.lua Script , give the result as follows :
Running results
3、Sublime Text Editor tools
I used to write php、py The language has used this sublime Editor , It can be regarded as an artifact editor , A variety of fancy style highlighting plugins , Just like , Just can't put it down . The official can try it for free , But you can also find the cracked version on Baidu and Google .
Official download address ( It seems that you need to climb over the wall to visit ):https://www.sublimetext.com/
Official website of Chinese version :[https://sublimetextcn.com/3/][https://sublimetextcn.com/3/]
After successful installation ; install Package Control Plug in tool center :
- 1、 Keyboard press
command + shift + pCall out Command input box - 2、 Input
install Package Control, Press enter - 3、 After successful installation , The window will pop up , Just make sure
- 4、 Again using
command + shift + p, Type... In the input boxInstall Package( The first input needs to wait for the link , Seconds ) After success, the input box will appear again , Then enter the plug-in you want to install , Choose , enter , You can install the plug-in .
Write a lua Script , Execution depends on the result :
-- Loop iteration local text = ' I hope my friends will pay more attention to ah mu : Thank you for your good code , And followed me !' print(text) ### I hope my friends will pay more attention to ah mu : Thank you for your good code , And followed me ! ### command + B function Here's the picture
Here we are ,Lua The language development environment has been set up !
4、 Write our first lua Script program ( It comes from the love of our young people )
--- From the network C Written language
--- lua Version as follows
function show_love()
local i, j, k, l, m
local text = ''
-- Leave space at the beginning 5 That's ok
for i=1,5 do
text = text .. "\n"
end
-- front 3 There is a gap in the middle of the line to write
for i = 1, 3, 1 do
-- Space on the left , There are fewer spaces to the left of each next line than the previous line 2 individual 8*n-2*i
for j = 1, 32-2*i do
text = text.." "
end
-- Output small characters in the left half
for k = 1, 4 * i + 1 do
text = text.."*"
end
-- The space in the middle , There are fewer spaces in each next line than in the previous line 4 individual
for l=1, 13-4*i do
text = text.." "
end
-- Output small characters in the right half
for m=1,4*i+1 do
text = text.."*"
end
-- After the output of each line, wrap the line
text = text.."\n"
end
-- Next 3 There is no space in the middle of the line
for i = 1, 3 do
-- Space on the left 8*(n-1)+1
for j=1,24+1 do
text = text.." "
end
-- Output character small love
for k = 1, 29 do
text = text.."*"
end
-- After the output of each line, wrap the line
text = text.."\n"
end
-- Next 7 That's ok
for i=7, 1, -1 do
-- Space on the left , There are fewer spaces to the left of each next line than the previous line 2 individual 8*(n+1)-2*i
for j=1,40-2*i do
text = text.." "
end
-- There are fewer characters in each next line than in the previous line 4 individual
for k=1, 4*i-1 do
text = text.."*"
end
-- After the output of each line, wrap the line
text = text.."\n"
end
-- The space to the left of the last line
for i=1,39 do
text = text.." "
end
-- The last character is little love
text = text.."*\n"
-- Finally vacate 5 That's ok
for i=1,5 do
text = text.."\n"
end
return text
end
print(show_love())The effect is as follows
***** *****
********* *********
************* *************
*****************************
*****************************
*****************************
***************************
***********************
*******************
***************
***********
*******
***
*summary
This chapter is very simple , Let me introduce you to my friends linux、mac、windows Lower installation lua; As well as the installation and... Of three common editors lua Plug in installation , Help us quickly develop . What's the problem? , Friends can leave messages !
Okay , I'm amu , Thank you for your good code , And followed me !️ ️ ️
边栏推荐
- Prefix and topic training
- Common coding and encryption in penetration testing
- Description of module data serial number positioning area code positioning refers to GBK code
- 阿里云全链路数据治理
- 软件性能测试分析与调优实践之路-JMeter对RPC服务的性能压测分析与调优-手稿节选
- Session & cookie details
- buuctf misc [UTCTF2020]docx
- Étalonnage de la caméra (objectif et principe d'étalonnage)
- PCL 点云按比率随机采样
- 【WordPress建站】6. 文章内容防复制
猜你喜欢
![[WUSTCTF2020]爬](/img/b6/4a0582144c3125e7a0666bbbbfe29d.png)
[WUSTCTF2020]爬

【图像融合】基于像素显着性结合小波变换实现多焦点和多光谱图像融合附matlab代码

阿里云全链路数据治理
![Selector (>, ~, +, [])](/img/7e/2becfcf7a7b2e743772deee5916caf.png)
Selector (>, ~, +, [])

How to open the soft keyboard in the computer, and how to open the soft keyboard in win10
![[signal recognition] signal modulation classification based on deep learning CNN with matlab code](/img/0b/7475cd4cf2ddce912816ab3c29b914.png)
[signal recognition] signal modulation classification based on deep learning CNN with matlab code

Accessing user interface settings using systemparametersinfo

两个链表的第一个公共节点_链表中环的入口(剑指offer)

RDD basic knowledge points

When MFC uses the console, the project path cannot have spaces or Chinese, otherwise an error will be reported. Lnk1342 fails to save the backup copy of the binary file to be edited, etc
随机推荐
How to open the soft keyboard in the computer, and how to open the soft keyboard in win10
MaxCompute远程连接,上传、下载数据文件操作
2.1.1 QML grammar foundation I
Counter attack from outsourcing to big factories! Android has been developed for 5 years, and after a year of dormancy, it has tried to become an offer harvester. Tencent has a fixed salary of 20*15
Deploy L2TP in VPN (medium)
[从零开始学习FPGA编程-42]:视野篇 - 后摩尔时代”芯片设计的技术演进-1-现状
[Proteus] Arduino uno + ds1307+lcd1602 time display
buuctf misc [UTCTF2020]docx
20个不容错过的ES6技巧
【图像分割】基于形态学实现视网膜血管分割附matlab代码
第三方软件测试公司如何选择?2022国内软件测试机构排名
When MFC uses the console, the project path cannot have spaces or Chinese, otherwise an error will be reported. Lnk1342 fails to save the backup copy of the binary file to be edited, etc
Deploy loglistener in tke container to collect logs to CLS
[机缘参悟-29]:鬼谷子-内揵篇-与上司交往的五种层次
Global and Chinese market of anion sanitary napkins 2022-2028: Research Report on technology, participants, trends, market size and share
MFC multithreaded semaphore csemaphore critical area and mutually exclusive events
[equalizer] bit error rate performance comparison simulation of LS equalizer, def equalizer and LMMSE equalizer
20 not to be missed ES6 tips
Learning to use BACnet gateway of building control system is not so difficult
The fund management of London gold is more important than others