imjustacowlol Posted March 6, 2014 Share Posted March 6, 2014 Hey guys, So quite a long time ago I had issues with switching maps at the part of clearing a world. Several weeks ago a update game because there was something missing in the engine itself, but when I switch with the same scripts I used before the 'fix' the game crashes without giving a reason. The scripts involved within map switching are App.lua and LoadLevel.lua. I don't see anything weird at the output tab in the debug editor, the general output tab does randomly say Error: Unknown client disconnected. I have no clue why the map switch works for others and not for me. I tried making a new project and the game would still crash. Here is a link to one of my main projects (it is 1.5gb yes, but I'm using most of the files in it so yeah..) https://www.dropbox.com/s/68ldy91jccykpdb/TestProject2.zip if you know the solution please let know Quote Link to comment Share on other sites More sharing options...
YouGroove Posted March 6, 2014 Share Posted March 6, 2014 Did you use some functions like : Clear() Or Release() on the world or maps ? There is some potential problems perhaps in the way of using them. Some other people have problems switching maps also. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted March 6, 2014 Share Posted March 6, 2014 What LoadLevel.lua file? I think klepto or something had one of these in the asset store that tried to do this inside an entity which will cause a crash. I can't download that big of a project man. You have to do a test app that is smaller. Quote Link to comment Share on other sites More sharing options...
imjustacowlol Posted March 7, 2014 Author Share Posted March 7, 2014 I'll make a smaller testmap for you today. Just came back from school so yeah ;/ Quote Link to comment Share on other sites More sharing options...
KTyJLXy Posted March 7, 2014 Share Posted March 7, 2014 You might wanna read this http://www.leadwerks.com/werkspace/topic/8845-selfworldclear-bug/ Quote Link to comment Share on other sites More sharing options...
imjustacowlol Posted March 7, 2014 Author Share Posted March 7, 2014 You can download my project here, its a significantly smaller file https://www.dropbox.com/s/68ldy91jccykpdb/TestProject2.zip still crashes upon clearing/releasing the world. Quote Link to comment Share on other sites More sharing options...
Rick Posted March 7, 2014 Share Posted March 7, 2014 Are you opted into the beta? Quote Link to comment Share on other sites More sharing options...
imjustacowlol Posted March 7, 2014 Author Share Posted March 7, 2014 Are you opted into the beta? I was but not anymore, doesn't work on either the beta or the normal. Quote Link to comment Share on other sites More sharing options...
Rick Posted March 7, 2014 Share Posted March 7, 2014 I'll test it out tonight. It does work so there is just something wrong with how you have it setup I'm thinking. Quote Link to comment Share on other sites More sharing options...
Rick Posted March 8, 2014 Share Posted March 8, 2014 You have the same issue as KTy. In your ShouldSwitchLevel() change self.world:Release() to self.world:Clear() and remove the creation of the new world. It should work then. If you get errors still it's probably because of the FPS script you might have in your scene. Quote Link to comment Share on other sites More sharing options...
imjustacowlol Posted March 8, 2014 Author Share Posted March 8, 2014 I'll take a look at it Still crashes if my ShouldSwitchLeve() is this: function App:ShouldSwitchLevel() if self.mapFile ~= "" then self.world:Clear() Map:Load(self.mapFile) self.mapFile = "" end end Next to that, the fpsplayer script is the default one by leadwerks. Quote Link to comment Share on other sites More sharing options...
Rick Posted March 8, 2014 Share Posted March 8, 2014 Next to that, the fpsplayer script is the default one by leadwerks. That doesn't matter. Changes were made to the engine and the FPSplayer script stayed the same causing some issues. Look in your output after the crash. Does it say it's deleting some things at the end of it? If so that means it started to clear and when it hit the fpsplayer it bombed. You can test this by taking out the player in your scene and put in a basic script where when you press a key it calls it switches the map. After I did this it doesn't bomb anymore, meaning the player script is causing the issue. Quote Link to comment Share on other sites More sharing options...
imjustacowlol Posted March 10, 2014 Author Share Posted March 10, 2014 [/size][/font][/color] That doesn't matter. Changes were made to the engine and the FPSplayer script stayed the same causing some issues. Look in your output after the crash. Does it say it's deleting some things at the end of it? If so that means it started to clear and when it hit the fpsplayer it bombed. You can test this by taking out the player in your scene and put in a basic script where when you press a key it calls it switches the map. After I did this it doesn't bomb anymore, meaning the player script is causing the issue. It does say it is deleting things yeah. But when I deleted the release parts in the player script, it still crashes for some reason. Perhaps I missed something, i'll take a look at it. The part where it goes wrong is actually after loading the next map 0_o --edit-- okay found another release part in player script, deleted that and still crashes with self.world:Release() but I fixed it by doing this: function App:ShouldSwitchLevel() if self.mapFile ~= "" then self.world:Release() self.world=World:Create() Map:Load(self.mapFile) self.mapFile = "" end end First self.world=World:Create() was not in the script, because that got advised earlier on. But by putting it back it did fix the crash. Here comes the new issue: The music from the previous level (There was music playing in that level) does not get released/deleted. Do I need to put an additional command in the ShouldSwitchLevel part to do so? Quote Link to comment Share on other sites More sharing options...
Rick Posted March 11, 2014 Share Posted March 11, 2014 Change self.world:Release() to self.world:Clear() and drop the creation of the new world. Then be sure to comment out the releasing in the player script. That must be a bug. Quote Link to comment Share on other sites More sharing options...
imjustacowlol Posted March 12, 2014 Author Share Posted March 12, 2014 Change self.world:Release() to self.world:Clear() and drop the creation of the new world. Then be sure to comment out the releasing in the player script. That must be a bug. Didn't work to get rid of the music. The music is attatched to an object with the Noise.lua script, and the object reaches throughout the whole map so everywhere you go you hear that song. When I either use Clear() or Release() in App.lua it doesnt delete the music. it's like something in the engine is registering that you are still in the previous map ánd in the new map that you loaded with the map-switch. Quote Link to comment Share on other sites More sharing options...
Rick Posted March 12, 2014 Share Posted March 12, 2014 "Maps" don't really exists in the Leadwerks API. All "maps" are is a collection of entities. A world holds a bunch of entities. So when you load a "map" it's just loading a bunch of entities in the current world. When you Clear() a world it's supposed to unload all entities in the world. If a sound continues to play then it's telling us that it's not getting unloaded when the world is clear. Go inside noise.lua and see if there is a function Script:Delete(). If there isn't then you probably have to add one and inside there stop the sound from playing. I don't have my main PC with LE setup so I can't check how noise.lua is setup, but this sounds like what is going on. Quote Link to comment Share on other sites More sharing options...
imjustacowlol Posted March 12, 2014 Author Share Posted March 12, 2014 Noise.lua is in the attatchment of this message. When I put Script:Delete() even anywhere in the Noise.lua script, it gives me an error: Script Error attempt to index global 'Script' (a nil value) Line 24 Noise.lua with the Script:Delete() is in the attatchment. When I replace Script:Delete() with Sound:Delete() or sound:Delete() it gives an error for the Delete part (doesn't matter if I write Delete or delete, gives the error anyway): Script Error attempt to index global 'Delete' (a nil value) Line 24 Noise.lua Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 12, 2014 Share Posted March 12, 2014 I don't see the Delete function in your attached script. You mean this function right:? function Script:Delete() self.source:Release() end Quote Link to comment Share on other sites More sharing options...
Rick Posted March 12, 2014 Share Posted March 12, 2014 You want the function Aggror has above. It might blow up on the Release() function because I think there is a bug so if it does just try calling :Stop() on the source instead to see if that at least stops the sound from playing, but try :Release() first. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted March 13, 2014 Share Posted March 13, 2014 . When you Clear() a world it's supposed to unload all entities in the world. If a sound continues to play then it's telling us that it's not getting unloaded when the world is clear. Should not it be automatic ? I mean clearing the world would stop and destroy all entities or process related to it could it be tables of entities, sound or whatever. As a world is just a list of instancied objects. Would perhaps be better in the future to have that done automatically for programmers and other people don't have to program more or care about ? Does it works like that on on other 3D egines ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
beo6 Posted March 13, 2014 Share Posted March 13, 2014 Having the choise to continue playing the sound is always better. If i want to have music continue playing while loading the next level would not be possible if the engine automatically removes all sounds when loading. Quote Link to comment Share on other sites More sharing options...
Rick Posted March 13, 2014 Share Posted March 13, 2014 I think that might lead to a memory leak though, because the entity the noise script is attached too would get removed automatically, which would mean our variable to the sound/source object isn't available to us anymore to do anything with. @YouGroove, I believe the entities that would get auto deleted would be the ones created in the scene. Because of the whole reference counting thing if you created it in code then you should delete it in code, because you might have passed it around, adding reference counts to it. Quote Link to comment Share on other sites More sharing options...
xtreampb Posted March 16, 2014 Share Posted March 16, 2014 also just a shot out in the dark, it appears (i'm don't know for sure) that anything that has to do with lua objects require the Script:delete() function as the world:clear calls this function (maybe recursively) until all entities are removed. if an entity doesn't have the delete function then it isn't removed from the world. Just an observation and thought I have. Quote bool Life() { while(death=false) { if(death==true) return death; } } I have found the secret to infinite life Did I help you out? Like my post! Link to comment Share on other sites More sharing options...
imjustacowlol Posted March 17, 2014 Author Share Posted March 17, 2014 I've been observing all solutions, and I'm sorry for my lack of reactions, but none of the solutions unfortinately have helped yet. Aggror's solution causes the game to crash upon map switch with self.world:Clear() again. and xtreampb, in what script should I put that piece of code? Quote Link to comment Share on other sites More sharing options...
xtreampb Posted March 17, 2014 Share Posted March 17, 2014 anything that has a script should have the delete function if my gut feelings are right. so in other words...all of them. Quote bool Life() { while(death=false) { if(death==true) return death; } } I have found the secret to infinite life Did I help you out? Like my post! 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.