sorry for the title but I don’t know how to name my problem in a better way . Basically what happened is that I had my prototype of a game working on PC and on my Android phone., then I made some changes to the code and it started crashing at a very specific point.
How to reproduce:
Launch the game
Click “Start”
Die (you can control the spaceship with your finger, just wait for the enemy ships to come from the top and get hit 4 times by their projectiles)
On “Game Over” screen click “Continue”
Click “Start” again
CRASH!
I thought it was some of my code doing it so I rerolled my code to the last version when it worked and the crash still happens at the exact same point. I tried to bundle on two different computers using Defold version 1.2.171. I don’t know what is causing the error because the crash dump is incomprehensible to me. If any of you have any suggestion I would be really grateful.
Edit: The last working version before it started crashing is in the Master branch. The develop branch contains the code after which it started crashing.
Note: This is my first ever game I am very new to game programming and LUA so excuse my code
And, by monkey patching the rnd.range function, it seems it gets a weird range “[1, 0]”. Since the extension is using unsigned ints, I’m guessing something goes bad in that function.
local old_fn = rnd.range
local function new_range(a, b)
print("MAWE range:", a, b)
return old_fn(a, b)
end
rnd.range = new_range
Let’s ping @selimanac, and maybe he can take a look at this?
I guess that this problem is partially on my end since I am not checking if the array is empty before taking its length and placing it in the range method. But as Mathias said it would be nice to have an actual Lua error instead of a crash.