PerEspen00 Posted April 13, 2017 Share Posted April 13, 2017 Hi, I have a keypad in my game but it crashes in a few cases. I have managed to pin point one thing that will cause it to crash, but I think there are more. Anyway, I've created a world where you can test and see if you can solve it. Problem 1: If you go in to the keypad, press some buttons, then go out. Then go in again, and press a button, it crashes every time. Not solved. Thanks in advance for any help or advice! Download link: http://www.mediafire.com/file/4h4g3d7tb79tt9e/Keypad123.zip Controlls: press right or left mouse button to enter the keypad, the camera will now move and the player will be locked. Now you can press with your mouse on the buttons you want to use. Press "E" to get unlocked from the keypad. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted April 13, 2017 Share Posted April 13, 2017 Commenting out, self:MakeNums(self.CurrentCode) in the update world loop stops the crash on the second time. But for the life of me I can't debug it with breakpoints. It's as if, with the function, it crashes second time around for a different reason? But without calling the function, it works... I'm going to need a coffee Quote Link to comment Share on other sites More sharing options...
macklebee Posted April 14, 2017 Share Posted April 14, 2017 Its due to trying to Release() something twice... function Script:RemoveNums() for i = 1, #self.NumPrefabs do self.NumPrefabs:Release() end end function Script:MakeNums(num) for i = 1, #self.NumPrefabs do if self.NumPrefabs ~= nil then self.NumPrefabs:Release() end end ... ... Releasing the sprites did not make them nil. So just change the code to: function Script:RemoveNums() for i = 1, #self.NumPrefabs do self.NumPrefabs:Release() self.NumPrefabs = nil end end function Script:MakeNums(num) if self.NumPrefabs[1] ~= nil then self:RemoveNums() end ... ... ... Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
PerEspen00 Posted April 14, 2017 Author Share Posted April 14, 2017 Thanks for the help, it works now! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.