Turbe$Z Posted November 2, 2019 Posted November 2, 2019 local table = { {"1", "2", "3", "4"}, } function asdasdsdasdd() table.insert(table,"5","6","7","8") end What wrong? No errors and warnings in debugscript 3...
Kenix Posted November 2, 2019 Posted November 2, 2019 (edited) Because table.insert inserts only 1 value to table. In your case you should use for loop and call table.insert per iteration. Please read Lua docs: Edited November 2, 2019 by Kenix 1
Turbe$Z Posted November 3, 2019 Author Posted November 3, 2019 2 hours ago, Kenix said: Because table.insert inserts only 1 value to table. In your case you should use for loop and call table.insert per iteration. Please read Lua docs: Ah, can you show me a example, please?
komal Posted November 3, 2019 Posted November 3, 2019 local table = { {"1", "2", "3", "4"}, } function startInsert() for k=5,8 do table.insert(table,tostring(k)) end end startInsert() 1
komal Posted November 3, 2019 Posted November 3, 2019 try your new code here https://www.Lua.org/cgi-bin/demo table = {"1","2","3"} function insertt() table[#table+1]="4" table[#table+1]="5" table[#table+1]="6" table[#table+1]="hello" table[#table+1]=7 table[#table+1]=8 for k,v in pairs(table) do print(v) end end insertt()
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now