Jump to content

Issues with a keypad


PerEspen00
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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 dry.png

Link to comment
Share on other sites

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

...

...

...

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...