27.07.2020, 06:01
You can use table.insert to add table elements at any position you need. Don't use table variable name because this will override table functions.
Code:
t = {0x01,0x02,0x03,0x04}
table.insert(t, 1, 0x0A) -- add as first table element
table.insert(t, 2, 0x0B) -- add as second table element
table.insert(t, 0x0C) -- add as last table element
table.insert(t, 0x0D) -- add as last table element
-- at this point table is { 0x0A, 0x0B, 0x01, 0x02, 0x03, 0x04, 0x0C, 0x0D }
str = string.char(unpack(t)) -- convert table to a binary string
loghex(str)