MadCat Posted October 3, 2016 Share Posted October 3, 2016 Hi All Having trouble with the change map coding, followed the tuts but when it goes to change the map it closes Help? What and where dose things go, like map name? --[[ This script will act as a trigger to change the current map. Place this at the end of your map to make the player progress to the next level. ]]-- Script.mapname=""--string "Map Name" function Script:Start() self.enabled=true end function Script:Collision(entity, position, normal, speed) changemapname=self.mapname end function Script:Enable()--in if self.enabled==false then self.enabled=true self:CallOutputs("Enable") end end function Script:Disable()--in if self.enabled then self.enabled=false self:CallOutputs("Disable") end end Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted October 3, 2016 Share Posted October 3, 2016 I assume you have attached this script to a trigger at the end of your scene? - Have you filled in the map name? Look app.lua or start.lua to see the variable changemapname. Once that variable has a value, the map is being changed. Not sure if that already included the .map extension. Quote Link to comment Share on other sites More sharing options...
MadCat Posted October 4, 2016 Author Share Posted October 4, 2016 Hi Just so you know I'm not a coder Yeah I changed the map name in (Script.mapname=""--string "Map Name") as the tut says and tested it and it dose is closes the test down Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted October 4, 2016 Share Posted October 4, 2016 Do you see anything in the log? most logical thing to me, is that your map can't be found. Either the map name is incorrect or the location might not be valid. Something to try: - Is your map located in the root of the scenes map? Or is it a submap? - have your tried with or without the .map extension? Quote Link to comment Share on other sites More sharing options...
MadCat Posted October 5, 2016 Author Share Posted October 5, 2016 I'll check all that Thanks Quote Link to comment Share on other sites More sharing options...
MadCat Posted October 6, 2016 Author Share Posted October 6, 2016 Ok I see that it's looking for the map in the wrong location (project) Quote Link to comment Share on other sites More sharing options...
MadCat Posted October 8, 2016 Author Share Posted October 8, 2016 Got it to work Just one thing, it takes a bit for it to load the next map What would be the best way to quicken that? Quote Link to comment Share on other sites More sharing options...
Rick Posted October 8, 2016 Share Posted October 8, 2016 So world:Clear() removes all the entities in that world. This means that when you call Load() on any entities it has to go to disk to load them (the slow part). If an entity (model/texture/material/etc) is already loaded and you call Load() on the same thing again LE uses instancing which will use the in memory loaded entity again instead of going to disk. This means that calling Load() on a resource that's already loaded is almost instant. Using this information it means you could load in code the models/textures/materials that all your maps have in common and never unload them so that when you load maps it uses those instances instead of going to disk, which would make the loading of maps faster. The thing I'm unsure of is if you can load those into another World object or if you have to load them into the same world as your map. If you can load them into a different World and instancing still works across worlds then make another World object and then make a map where you just drag in 1 of all the models/textures/materials that are common between maps (you are basically making a map of preloaded things). Then load that map when that world is active World:SetCurrent() I think it is. You might have to call preloadWorld:Hide() or loop through all the entities in that world and call Hide() on them so they don't show up because you don't want to see them just have them loaded in memory. Now set the default world as current and continue as normal. Now, if instances can only be used in the same world (I doubt this is the case) you'd have identify these models/textures/materials somehow and then when unloading instead of just calling Clear() on the world you'd have to loop over all entities and release them except these preloaded ones you'd want to stick around. 1 Quote Link to comment Share on other sites More sharing options...
MadCat Posted October 9, 2016 Author Share Posted October 9, 2016 The call preloadWorld:Hide() sounds like the thing I need As I'm not a coder and I start learning code next year, I'm not shore how to get that to work Quote Link to comment Share on other sites More sharing options...
Roland Posted October 9, 2016 Share Posted October 9, 2016 "preloadWorld:Hide()" ... another of those undocumented things? Can't find that one Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
Rick Posted October 9, 2016 Share Posted October 9, 2016 No, that's just the idea of what you might be able to do. Make another world and load a map into that world. That map has just 1 of each asset in it that you may use between other maps. If you call that world preloadWorld you may (not sure) be able to call Hide() on it to hide all the entities loaded inside it. If not then you have to loop over said world and call Hide() on each entity. 1 Quote Link to comment Share on other sites More sharing options...
MadCat Posted October 10, 2016 Author Share Posted October 10, 2016 I supose the other way is to make a Loading Screen But I'm not shore how to code that ether Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted October 10, 2016 Share Posted October 10, 2016 I supose the other way is to make a Loading Screen But I'm not shore how to code that ether When you trigger a function that loads your maps, have a boolean set that displays a loading screen. On the next update draw the texture and then load your map. This results in the drawing context not being cleared (and thus keeping the loading screen displayed). Quote Link to comment Share on other sites More sharing options...
MadCat Posted October 10, 2016 Author Share Posted October 10, 2016 To be very honest with you guys, I don't actually know how to read code 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.