Turbe$Z Posted November 2, 2019 Share 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... Link to comment
Kenix Posted November 2, 2019 Share 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 Link to comment
Turbe$Z Posted November 3, 2019 Author Share 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? Link to comment
Overkillz Posted November 3, 2019 Share Posted November 3, 2019 Here you have an example. Just try it. 2 Link to comment
komal Posted November 3, 2019 Share 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 Link to comment
komal Posted November 3, 2019 Share 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() Link to comment
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