Jump to content

Change Map Code?


MadCat
 Share

Recommended Posts

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

  • Upvote 1
Link to comment
Share on other sites

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.

  • Upvote 1
Link to comment
Share on other sites

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).
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...