Alienhead Posted yesterday at 02:10 AM Share Posted yesterday at 02:10 AM I'm attempting to clear an active world.. Say the player wishes to restart the map, not a /sav but a complete restart of the map that loaded upon entering the game. So far I'm attempting to do it this way: if window:KeyHit(KEY_F2) then scene=nil collectgarbage() scene = LoadMap(world, mapname) end But it leaves stuff behind, decals, and any other entity or game object I have referenced elsewhere in my code. Sure could use some advice on this one, I'm stumped. I know this will be a question asked 100's of time once you get 1.0 released customers in here... Do you think it may be a big enough deal to include a world:Clear() / world:Unload() / scene:Wipe() / scene:Kill() or something ? As it stands Im pretty much guessing and hoping stuff got cleared with nil, its not reassuring. If not, then maybe a clear path to as what needs to be done to restart a map without lingering 'things' in the world/scene. Quote Link1 || Alienhead Components and Software || Link2 Link to comment Share on other sites More sharing options...
reepblue Posted yesterday at 02:57 AM Share Posted yesterday at 02:57 AM Sounds like you have objects/pointers still in use. Ultra Engine uses smart pointers and if something is still pointing to an object or entity, the entity will not be deleted. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Alienhead Posted yesterday at 03:42 AM Author Share Posted yesterday at 03:42 AM Going to be pretty rough clearing a map/scene all the way out then. Guess I'll just have to go through all my code and grab all the table and variable names pointing to something. So for example, something like the player component, which opens up a lot of tables and variables on it's own, won't scene = nil kill the player component and thus all it contains ? Or I'm still needing to clear that first before scene = nil? Thanks. Quote Link1 || Alienhead Components and Software || Link2 Link to comment Share on other sites More sharing options...
Dreikblack Posted yesterday at 04:04 AM Share Posted yesterday at 04:04 AM 22 minutes ago, Alienhead said: won't scene = nil kill the player component and thus all it contains ? Should be enough if there is no other pointers to this entity and component. Also scene could be saved somewhere Quote Link to comment Share on other sites More sharing options...
reepblue Posted yesterday at 04:07 AM Share Posted yesterday at 04:07 AM A scene can be cleared without deleting an entity if the entity is still being referenced by something else. In C++, this would normally mean you're using another shared pointer as a reference when you should be using a weak pointer. No clue about Lua to be honest. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! 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.