theonlysnowflake Posted September 20, 2015 Share Posted September 20, 2015 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??? Quote Link to comment Share on other sites More sharing options...
mdgunn Posted October 2, 2015 Share Posted October 2, 2015 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. 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.