Phodex Games Posted May 10, 2018 Share Posted May 10, 2018 Hey its me again. I had a similar problem some time ago, but this time its diffrent and I still did not found a solid solution. So when I tried to load a new map like this, world:Clear() Map:Load("Map path") it just crashes, without any error or anything. After some testing and deleting diffrent stuff step by step I got a object reference count error. This is pretty frustrating :(. Well I know its due to my code, but sometimes I lack some bascis as I learnt the whole coding stuff by myself. I nailed down the problem by trial and error. It seems to be my AI/Characters and weapons equipped to the player and the AI, had no energy yet to do deeper research on this. I am just wondering how you generally deal with such an issue. I have this problem very often, if I want to release an object it just crashes (for example it is playing an animation atm, or used elsewhere in code), so I need to fiddle around, using self.entity:Hide(), or do some workarounds to prevents this. I know there is self.entity:AddRef(), but how to best use this to prevent my game from crashing? I am a little bit helpless and so close to the release, I need to fix this! Quote Link to comment Share on other sites More sharing options...
gamecreator Posted May 10, 2018 Share Posted May 10, 2018 This might help you: https://www.leadwerks.com/community/topic/15557-world-entity-release/?do=findComment&comment=104013 Not sure if it's available in Lua. 1 Quote Link to comment Share on other sites More sharing options...
tipforeveryone Posted May 10, 2018 Share Posted May 10, 2018 The best way to change map which I learnt is change the value of changemapname variable (it is a global one) in the main.lua instead of using Map:Load() in any script. This prevents game to crash in most cases. I got this problem before when I use Map:Load() in Script:UpdateWorld() or Script:UpdatePhysics(), loading map like this will cause errors like "assert error" or some entites not found (nil) even they are in code. Hope this help 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted May 11, 2018 Share Posted May 11, 2018 It depends on where you are calling this code. If you are calling it inside an entity script function, the results could be disastrous because you are telling the engine to delete an entity that is currently having a script run on it. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Ma-Shell Posted May 11, 2018 Share Posted May 11, 2018 2 hours ago, Josh said: It depends on where you are calling this code. If you are calling it inside an entity script function, the results could be disastrous because you are telling the engine to delete an entity that is currently having a script run on it. I think, the engine should call addref before calling a hook in a script and release afterwards. This way this could never lead to a problem like this and there would be no harm in doing so, since in this event the world would first release its reference and after the object was done with its current hook it would be deleted. Quote Link to comment Share on other sites More sharing options...
Solution Phodex Games Posted May 13, 2018 Author Solution Share Posted May 13, 2018 I fixed the problem on my own now. After disabling various things and doing the map change in main loop I could nail down the problem. It was caused by many diffrent sources and turned out to be pretty complex, still could fix it luckily. Thanks for all who posted, your information was helpful indeed.e 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.