I’m getting this error on a module containing some level data, resulting in a bunch of other errors in the script that requires it:
ERROR:SCRIPT: /zones/test_level/test_level.lua:3: attempt to index a nil value
stack traceback:
/zones/test_level/test_level.lua:3: in main chunk
[C]: in function 'require'
/sonic/sonic#.script:104: in function </sonic/sonic#.script:100>
The weird thing is that this module worked perfectly fine before, and I haven’t touched it in some time. There aren’t any other errors above it in the console, so I can’t tell why this is happening. Here’s the module code:
I find it even more weird that you say it worked in the first place.
You are creating a table and putting it in M
M = {}
But then the table contains nothing (nil) so trying to index another table within that table is impossible as it hasnt been created.
M[1] = nil
Just a question regarding the error message, but I guess it is more regarding Lua than Defold, but maybe: can it point out immediately which value actually is trying to be indexed, but is nil?
I mean a general use-case for debugging such message is indeed printing out the values, but I dreamed about it to be done for me in this log because, you know, sometimes I have in on line: if table1[i] and table2[i] and table3[i] and so on in one line and is taking sooooo much time to print them all jk I don’t think there’s monkey patch solution for conditions, right?