Having an issue with defold-tilemap-animator asset

So, like it’s name, this asset animates tilemap animations.

I got it working. It animates the tiles just fine. However, I’m getting

ERROR:SCRIPT: /dta/dta.lua:192: bad argument #1 to ‘pairs’ (table expected, got nil)
stack traceback:
[C]: in function ‘pairs’
/dta/dta.lua:192: in function ‘set_tile_loop’
/dta/dta.lua:204: in function </dta/dta.lua:197>

I’m getting alot of this same error over and over again. Is this a cause for concern? Is this an issue with the asset dependency? Can someone help me find a solution, because I think I’m doing everything right. After all, the asset is working properly.

The error complains about a nil value being passed to a ipairs on line 192. So if you check that line (https://github.com/gymratgames/defold-tilemap-animator/blob/master/dta/dta.lua#L192)
you’ll see it’s being passed the dta.tilemap_tiles[start_tile] value. Since that value is nil, the question is, when is it set to a proper value?

Let’s ping the author @WhiteBoxDev for further help.

1 Like

Yea that’s what I thought the issue is. I’m looking through the asset code to try to figure out the issue.

Could it be an async issue?

What is the value of the start_tile that you pass in?

return {
[353] = { end_tile = 360, playback = “loop_forward”, step = step },
[397] = { end_tile = 404, playback = “loop_forward”, step = step },
[441] = { end_tile = 448, playback = “loop_forward”, step = step },
[485] = { end_tile = 492, playback = “loop_forward”, step = step },
[529] = { end_tile = 536, playback = “loop_forward”, step = step },
[551] = { end_tile = 558, playback = “loop_forward”, step = step },
[595] = { end_tile = 602, playback = “loop_forward”, step = step },
[617] = { end_tile = 624, playback = “loop_forward”, step = step },
[499] = { end_tile = 506, playback = “loop_forward”, step = step },
[521] = { end_tile = 528, playback = “loop_forward”, step = step },
[543] = { end_tile = 550, playback = “loop_forward”, step = step },
[565] = { end_tile = 572, playback = “loop_forward”, step = step },
[587] = { end_tile = 594, playback = “loop_forward”, step = step },
[609] = { end_tile = 616, playback = “loop_forward”, step = step },
[631] = { end_tile = 638, playback = “loop_forward”, step = step },
[653] = { end_tile = 660, playback = “loop_forward”, step = step }
}

That’s the object that’s passed into the module. start_tile refers to the numbers that are the keys.

Yes, and what is the value of start_tile?
Is that index present in the table?

Strange. I don’t see anything wrong with the info you provided so far. Could you share your project with me gymratgames@gmail.com so I can take a look?

I sent a link to my repo. Thanks for looking into it.

1 Like

Diagnosed the issue! Turns out you’re only using two distinct animated tiles in your tilemap, despite having listed 16 animation groups in your animations.lua module. Obviously this shouldn’t be a problem, but DTA expects all animation groups to be present at least once in the tilemap.

I’ll update the repo soon to fix this bug. Thanks for sharing. You don’t have to change anything, however if you don’t want to see the errors in the meantime, you can comment out the animation groups that aren’t being used in your tilemap while you’re working on it.

Excellent. Thanks for helping with this issue, and thanks for your module as well. Really comes in clutch.

1 Like

I pushed to master. You should immediately get the update since your game.project file references master instead of a release. Let me know if you run into any more issues.

I plan to give DTA a rewrite with some more functions soon.

1 Like

I’m having an issue with my collision groups in my tilemaps, and I’m pretty sure I’m setting everything properly. I even compared my configs to a project where it’s working properly. The only difference seems to be using defold-tilemap-animator in the project where the collision groups aren’t working. Could DTA be causing the issue?

The collision groups shouldn’t be any different since DTA doesn’t touch those. Make sure you’re setting them like normal in your tilesource file and using a collisionobject along with your tilemap in the editor.

If no luck, then go ahead and email a version of your project again that contains the collision problem and I will take a look.

It doesn’t look like this is a problem relating to DTA. Unfortunately, I tried to fix your problem by checking over your collision settings, however I’m not sure what the solution is. Seems like your collisions should be detected in your player’s on_message function.

I also removed all references to DTA and unlinked the library from your game.project file, which didn’t fix the issue. May need to make another forum topic about this and post your project there so others can take a look.

Will do. Thanks again for taking the time.