当前位置: 首页 > news >正文

use lua

-- basic.lua
print("hello ".."world")
local a = 1 --only this file can see
b = 2 -- global see
-- not declare vaiable all asign to nil
print(fuck)
-- 字符串可以"" ,'' ,[[]]
-- 一些数值运算支持,进制数,科学数,shift移
function f(a,b)print(a,b)return a + b,a - b
endlocal sum,sub = f(1,2)
--table
local arr = {1,"hell",{},function() end}
-- index start from 1
print(arr[4])
print(#arr)
table.insert(arr,1,"fuck")
local name_table = {a=1,b="1111",c=function ()return "yes"    end,d={}
}
print(name_table["c"])--get the value
--全局表_G
print(_G["table"]["insert"])
print(_G["b"])-- see the above global vaiable b-- control flow
if 1+1 == 2 then
print(true)
elseif 1+1==3 and 1+1 == 0 then
print(false)--0 is true,only nil is false
else print("what ever")
end-- start end step
for i=10,1,-1 doprint(i)--this i just can read not writeif i == 5 thenbreakend
endlocal n = 10
while n > 1 doprint(n)n = n - 1 --not support -- ++if n==5 thenbreakend
end-- this module can return varlue
return 1
-- multi-file.lua
-- auto run the file basic.lua code
local basic = require("basic")--and get the return from file basic.lua
print("b is ",b)-- get the basic global vaiable b
print(basic)
print(package.path)--?.lua, ?会被文件名替代
-- example.lua
local example = {}
function example.hello()print("hello")
end
return example
-- use-example.lua
local example = require("example")
example.hello()

vscode key bind

  1. Ctrl + e
  2. Home
  3. End
http://www.lryc.cn/news/110267.html

相关文章:

  • 网络——初识网络
  • 调试技巧(2)
  • 骨传导耳机真不伤耳吗?骨传导耳机有什么好处?
  • mac切换jdk版本
  • go 基本语法(简单案例)
  • Permute 3 for mac音视频格式转换
  • 线程概念linux
  • 【Yolov5+Deepsort】训练自己的数据集(1)| 目标检测追踪 | 轨迹绘制
  • express学习笔记4 - 热更新以及express-boom
  • Ajax_02学习笔记(源码 + 图书管理业务 + 以及 个人信息修改功能)
  • Python-数据类型转换
  • DASCTF 2023 0X401七月暑期挑战赛 Web方向 EzFlask ez_cms MyPicDisk 详细题解wp
  • 数据结构-链表
  • 大数据Flink(五十五):Flink架构体系
  • 使用矢量数据库打造全新的搜索引擎
  • 算法提高-树状数组
  • Django ORM详解:最全面的数据库处理指南
  • Istio 安全 授权管理AuthorizationPolicy
  • 04 Ubuntu中的中文输入法的安装
  • faac内存开销较大,为方便嵌入式设备使用进行优化(valgrind使用)
  • 分数线划定(c++题解)
  • React 在 html 中 CDN 引入(包含 antd、axios ....)
  • 数据结构----异或
  • PHP Smarty模板的语法规则是怎样的?
  • Socks IP轮换:为什么是数据挖掘和Web爬取的最佳选择?
  • 优化|当机器学习上运筹学:PyEPO与端对端预测后优化
  • Cocos Creator的 Cannot read property ‘applyForce‘ of undefined报错
  • 纯css实现九宫格图片
  • 【MySQL】数据库的增删查改+备份与恢复
  • Docker 部署 redis 举例