--[[LUA table processing]]--alice = {} alice["name"] = "Liuhui" alice["phone"] = "15157121639" alice["address"] = "Hangzhou Jianggan" Alic e["City" = "Hangzhou" Print (alice["name"]) print (alice["City") print (alice.city)--[[with {} processing assignment after each statement,]]--m Ytab = {["name"] = "Liuhui", ["xingbie"] = "male", ["Age"] =24,} mytab1 = {name = "Xiaohui", email = "liuhui331234958@12 6.com ",} print (Mytab.name) print (mytab1.email)--[[use the table as an array]]--tab1 = {" abc "," Def "," Mok "," Liuhui ",} tab2 = {[1] = "abc", [2] = "Def", [3] = "Mok",}--[[Lua array is calculated from 1]]----[[Print (tab1[1])]]--print ("TAB1 print:") len = #tab1 for I=1, Len do print (tab1[i]) i = i + 1 end print ("TaB2 printing:") len = #tab2 for I=1, Len do print (tab2[i]) i = i + 1 End tab1[5] = "hehe" Print (Tab1[4]) print (tab1[5])--[[more standard array add element procedure Table.insert If no second argument is added to end]]--table.in SERT (TAB1, 6, "Nihao") print (tab1[6])--[[remove element Table.remove from the array, similar to Table.insert]]--print ("delete tab1[1]") print ("before deleting Length is: ". #tab1: " Content is ") foR I=1, #tab1 do print (Tab1[i]) end Table.remove (TAB1, 1) print ("After delete length:" ...) #tab1)--[[The second element in the original array is shown here, the default is to move forward one]]--for I=1, #tab1 do print (Tab1[i]) end Table.remove (tab1)--[[Delete without the delete label defaults to The last element deletes]]--print ("Deleted length:" ...). #tab1) for I=1, #tab1 the Do print (Tab1[i]) end--[[array to sort]]--array = {"Liuhui", "haha", "abc", "Zero",} table.sort ( Array) for I=1, #array do print (Array[i]) end--[[array Add function name]]--function prtmsg (str) Local msg = str return msg E nd function Prttype (str) Local ret = "" if (type (str) = = "string") then ret = "string" Return ret ElseIf (type (str) = = "Double") then ret = "Double" return ret else return ret end end util = {} Util.func = prtmsg Util.type = prttype m str = "Hello" print ("message type:"). Util.type (MSTR)) print ("Message info:"). Util.func ("Hello"))