shift values ??in the table or reindexing table

Hello!

I have a table, for example Test = {}
and I filled it with images.

Test[1] = img1
Test[2] = img2
Test[3] = img3

In some cases I want to delete the img1 and I want to shift another images to the beginning of the table/array or reindex this table:

Table[1] = img2
Table[2] = img3
Table[3] must be empty.

I know, I can do it with a loop with code which is rewrite this array.

But maybe lua have the standart way for deleting the item and automatically shifting them to start or reindexing table [import]uid: 106224 topic_id: 31420 reply_id: 331420[/import]

table.remove(Table,1)  

[import]uid: 142361 topic_id: 31420 reply_id: 125659[/import]

Thanks, I found it too. But in the sources I saw something like that: “use table library”

Is it means I must to connect this library manually?

Something like this?

require (“table”) [import]uid: 106224 topic_id: 31420 reply_id: 125708[/import]

Well, you probably won’t, as table is a standard library (like string, coroutine, math, debug, etc…).
It comes with Lua, and I’m pretty sure Corona handles it perfectly.
So you won’t need to require ‘table’, or any standard library. [import]uid: 142361 topic_id: 31420 reply_id: 125715[/import]

Thanks! [import]uid: 106224 topic_id: 31420 reply_id: 125717[/import]

table.remove(Table,1)  

[import]uid: 142361 topic_id: 31420 reply_id: 125659[/import]

Thanks, I found it too. But in the sources I saw something like that: “use table library”

Is it means I must to connect this library manually?

Something like this?

require (“table”) [import]uid: 106224 topic_id: 31420 reply_id: 125708[/import]

Well, you probably won’t, as table is a standard library (like string, coroutine, math, debug, etc…).
It comes with Lua, and I’m pretty sure Corona handles it perfectly.
So you won’t need to require ‘table’, or any standard library. [import]uid: 142361 topic_id: 31420 reply_id: 125715[/import]

Thanks! [import]uid: 106224 topic_id: 31420 reply_id: 125717[/import]

For some reason when I use table.remove my table is not being reindexed… any ideas why?? The code Im using is something like:

local transList = {}

local adjustedOnComplete = function(obj)

        local indexObj = obj.indexTransition

        table.remove( transList , indexObj )

end

local addTransition = function(object, params)

    local index = #transList+1

    local idTransition

        

    object.indexTransition = index

    params.onComplete = adjustedOnComplete

    idTransition = transition.to(object, params)

    transList[index] = { id = idTransition }

end


The code runs smoothly except that when I need to create a new transition the index it gets is always +1 from the previous (even when the previous transition has ended already and its entry was already removed from transList by adjustedOnComplete()

Any ideas?

For some reason when I use table.remove my table is not being reindexed… any ideas why?? The code Im using is something like:

local transList = {}

local adjustedOnComplete = function(obj)

        local indexObj = obj.indexTransition

        table.remove( transList , indexObj )

end

local addTransition = function(object, params)

    local index = #transList+1

    local idTransition

        

    object.indexTransition = index

    params.onComplete = adjustedOnComplete

    idTransition = transition.to(object, params)

    transList[index] = { id = idTransition }

end


The code runs smoothly except that when I need to create a new transition the index it gets is always +1 from the previous (even when the previous transition has ended already and its entry was already removed from transList by adjustedOnComplete()

Any ideas?