Jump to content

theonlysnowflake
 Share

Recommended Posts

I am trying to make it so when you press space it advances to the next map, but am having a little trouble. I have it embedded in the Player (for the ball game template). Here's what I have

 


Script.mapname=""--string "Map Name"

if self.levelcomplete then
 if window:KeyHit(Key.Space) then
  return Map:Load("Maps/"..self.mapname)
 end

 

When I hit space, the text disappears and reappers really fast. It's doing something, but I don't know what. Are there any suggestions???

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

 

I believe that if you change a variable named 'changemapname' then the main game loop that is running through Main.lua will pick up on the change in this 'secret' global variable and change the map for you.

 

-- FROM standard MAIN.LUA template
--Handle map change
if changemapname~=nil then

--Clear all entities
world:Clear()

--Load the next map
Time:Pause()
if Map:Load("Maps/"..changemapname..".map")==false then return end
Time:Resume()

changemapname = nil
end

 

You don't need .map on the end or other path info, just make sure the map you want to load is in Maps directory because as you can see in the code above this is where it will look.

 

It's not the only way to do it but as it's sort of a built in global variable that is used in the standard Main.lua template it is one of the intended ways to do it. There is also a TriggerChangeMap.lua script.

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