Jump to content

Map switch script works for others, but not for me?


cowlol
 Share

Recommended Posts

Hey guys,

 

I can not upload the whole project for you guys to see what the problem is, because I can only upload 500kb to the forums, and the whole project is around 600mb. But let me describe the problem:

 

Piller made a script to load new maps, along with some changes in the App.lua script. Both scripts for map switching can be found in the attached files.

 

The scripts work like this: you attatch the LoadLevel.lua script to an object, which its collision type is set to Trigger. At the scripts tab for that object you select the map you want it to load as soon as you enter the trigger. So when you walk in the trigger it should be loading the new map and unloading the old map. But if I want to switch in-game from start.map to lol.map (start.map is my main level, it's quite big) it gives this error:

Debug Assertion Failed!

 

Program:

...ents\Leadwerks\Projects\buildandshoot\buildandshoot.debug.exe

File: c:\program files (x86)\microsoft visual studio

12.0\vc\include\vector

Line: 1442

 

Expression: vector erase iterator outside range

For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.

 

(Press Retry to debug the application)

 

Now the part where it gets oddly interesting is here: when I begin in lol.map and I want to switch in-game to start.map by entering a trigger inside of lol.map which is linked to start.map I get this:

 

Failed to read file ''C:\Users\(I hide my name here)\Documents\Leadwerks\Projects\buildandshoot''

 

So when I use the script from one map, it gives the one error, and from the other map it gives the other error. I also made a test-project on advise of Piller, with 2 maps built out of objects that were with Leadwerks already. Faild to read file error on those 2 maps. lol.map (from the main project) is also only build out of objects that already were with leadwerks, start.map contains models and textures that I imported myself (which might have something to do with it).

 

Now the part that I think is very important on the first error is this:

Program:

...ents\Leadwerks\Projects\buildandshoot\buildandshoot.debug.exe

File: c:\program files (x86)\microsoft visual studio

12.0\vc\include\vector

Line: 1442

 

what does microsoft visual studio 12.0\vc\include\vector to do with all this?

 

Hopefully someone can help me out. Piller has tried very hard as well, but me and Piller didn't manage to solve it yet. The weird part is: when I send him the scripts (App.lua and LoadLevel.lua) they work perfectly fine for him.

 

specs:

Windows 8.1

nvidia gtx 650 ti

8gb ram

intel core i5-3470 CPU @ 3.20 ghz (this is a quad-core processor)

 

ps,

If you do want to have the full project so you can see everything I have, how do I upload it to those forums or where else should I upload it?

 

---edit---

the project we were initially talking about, with failing map switch:

https://www.dropbox.com/s/i7gxqtcwel3twdj/buildandshoot.zip

 

download file for a project where the normal launcher crashes, but debugger works fine (also with map switch failing):

https://www.dropbox.com/s/vk4bjtt8b8pkzwe/AlienInsurgency.zip

 

yes they are both about the same, except for the name.

App.lua

LoadLevel.lua

Link to comment
Share on other sites

Your App.lua map variable is not declared anywhere.

You have removed local mapfile declaration :

 

 

 

 --local mapfile = System:GetProperty("map","Maps/start.map")
self.mapFile = "Maps/lol.map"
if Map:Load(self.mapFile)==false then return false end
self.mapFile = ""

 

 

So you need to declaring in App.lua first line :

 

Script.mapfile = nil

 

If you plan to use some self.map variable, or am i wrong ?

 

----------

 

Some questions :

If you use Lua and Steam edition, you should not have any Visual Studio C++ problems.

Are you makings special C++ stuff mixed with Lua ?

 

 

Expression: vector erase iterator outside range

For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.

 

This would mean you have some value out of range, i don't kwno what you do in specific C++, you just have to LOG the vector problem on a file to do some debug.

 

Failed to read file ''C:\Users\(I hide my name here)\Documents\Leadwerks\Projects\buildandshoot''

 

When does this happen ? When loading map in the editor or running the game ?

Perhaps it's a corrupted map ?

 

Could you post a screenshot of your editor showing this error to see the error logs ?

Stop toying and make games

Link to comment
Share on other sites

the project we were initially talking about, with failing map switch:

https://www.dropbox.com/s/i7gxqtcwel3twdj/buildandshoot.zip

 

download file for a project where the normal launcher crashes, but debugger works fine (also with map switch failing):

https://www.dropbox.com/s/vk4bjtt8b8pkzwe/AlienInsurgency.zip

 

yes they are both about the same, except for the name.

Link to comment
Share on other sites

I mean inside Start() or any other function, but mostly Start(), you can make variables by using:

 

self.MyVariable = "Rick"

 

and then use those anywhere in that script.

 

Script. is mainly used for 2 purposes. If what you are making is a table variable, then it spans multiple instances of the same script attached (it's shared between them). The other reason is mainly for exposing parameters in the editor. Other than that, there isn't a language reason to make Script. variables besides trying to use it as a pretty way to show what variables are used in this script (which isn't required but can be a nice convention to use).

Link to comment
Share on other sites

@cowlol :

 

Anyway, nice game prototyping.

 

Downloaded your first link.

I got a problem only using the debug version.

bug3.jpg

 

I would say always publish the NO debug version, just publish RUN version and you won't have that problem.

I think running debug version outside of the editor is problematic and debug version should be only possible using the editor.

 

Your link is big 600mo, i seen it has lot of stuff that is not used in your game.

You should publish your game this way your game publishing will only contain what is used in your game and will be lot more smaller.

 

---------------

 

Downloaded your second file :

All is ok on debug mode.

When running the map in "Run" mode i got one error after wlaking or side strafing a little in the room ?

I got also a read only memory error ?

Have you some special script ? or trigger ?

Also loading your game i see in the log a sound is missing.

Really strange.

Stop toying and make games

Link to comment
Share on other sites

@cowlol :

 

Anyway, nice game prototyping.

 

Downloaded your first link.

I got a problem only using the debug version.

 

 

I would say always publish the NO debug version, just publish RUN version and you won't have that problem.

I think running debug version outside of the editor is problematic and debug version should be only possible using the editor.

 

Your link is big 600mo, i seen it has lot of stuff that is not used in your game.

You should publish your game this way your game publishing will only contain what is used in your game and will be lot more smaller.

 

Well, the reason the game crashes (if you have followed the topic) is because you enter the wooden block that should load a new map. But the fact that that error is there, is the whole problem why this topic is at bug report. Next to that this game isn't the final product yet, I still got several weeks of development ahead. I will delete all useless files as soon as it is completed.

 

When launching the non-debug version the game should crash without an error message.

Link to comment
Share on other sites

I tried this out and it crashes when the world is released. That should help Josh pinpoint why it's crashing. I even made a smaller test map with his project and same crash. Something about what's built into the exe seems to be causing it.

Link to comment
Share on other sites

ok

 

Why loading a level, as you have interior and exterior already ? what do you want to load more ?

 

 

------------

 

A bug on BSP geometry :

 

bug4.jpg

 

-----------

 

 

Last time i used succesfully map changing, im' not sure i used World commands like you've done :

self.world:Release()
self.world = World:Create()
Map:Load(self.map)

 

Another point , you put directly "lol.map" on slot of script Loadlevel.lua

It shoumd be like in App.lua "Maps/lol.map"

 

 

--------------

 

I changed code in App.lua ot that :

 

--This is our main program loop and will be called continuously until the program ends

function App:Loop()

 if self.window:KeyHit(Key.H) then

self.world:Release()

self.world = World:Create()

Map:Load("Maps/lol.map")
end

 

same problem with that code.

 

I remember having also a problem with map changing, i finished to resolve it after lot of tries.

I'll see if i can find that old thread.

Stop toying and make games

Link to comment
Share on other sites

OK here is the solution :

refering to my old SOLUTION THREAD THAT SHOULD BE PINNED SOMEWHERE OR IN WIKI :

http://www.leadwerks.com/werkspace/topic/7804-tutorial-lua-map-changing/page__hl__map+load

 

I changed your code in App.lua to test more easy : it just works great smile.png

 

--This is our main program loop and will be called continuously until the program ends
function App:Loop()

 if self.window:KeyHit(Key.H) then

--self.world:Release()

self.world = World:Create()

Map:Load("Maps/lol.map")
end

if self.window:KeyHit(Key.J) then

--self.world:Release()

self.world = World:Create()

Map:Load("Maps/start.map")
end

...
...

 

In fact NEVER use the command : WORLD:RELEASE() and all will be ok.

Just tested level switching with your maps multiple tims without any problem.

 

Second point : never forget that maps are referenced from Map system folder so adress them always with

"Maps/mymap.map"

Could it be in code or using some drag and drop slot.

 

 

@Rick:

I don't understand why it worked on your tutorial map changing ? (http://www.leadwerks.com/werkspace/topic/8103-gameplay-tutorial-requests-here/)

but didn't worked for me some time ago( old thread), and solution i posted without the command world:release() worked finally for me and works with actual bug report that posted cowlol.

Stop toying and make games

Link to comment
Share on other sites

I think this would leave the old world loaded, which means the old world entities as well. Do this a bunch of times in a row and watch your memory and I would think it would keep going up. I could be wrong, but I think releasing the world is the right thing to do. It works right now for me to release the world as well. It's just his version that doesn't seem to work.

Link to comment
Share on other sites

Do this a bunch of times in a row and watch your memory and I would think it would keep going up. I could be wrong

Just tested whatching Windows process, very stable no increase of memory switching multiple times, i even had some memory decrease at some map switches (perhaps because second map is really small)

 

 

but I think releasing the world is the right thing to do.

I don't know but actually it works without release(), and using it just crahes, and crashed with another project test i had.

Perhaps if you use more complex maps and really different ones the problem will happen ?

 

It works right now for me to release the world as well. It's just his version that doesn't seem to work.

This is not a version but general problem , see my old thread from Nov 2013 when i used Leadwerks 3.0

http://www.leadwerks.com/werkspace/topic/7804-tutorial-lua-map-changing/page__hl__map+load

Nobody could find a solution or what hell was going on and i finally find out that simple solution.

 

Well the best could be to ask Josh to try to make work or debug World:release with actual test levels.

This command have a problem or bug indeed ,and it is blocking if you use it.

Stop toying and make games

Link to comment
Share on other sites

It is awesome that you can switch worlds by pressing h and j, but how can you switch world by entering specific objects then? Because that is my goal: when entering an (invisible) object (set as a trigger), a new map will load.

 

When making this App.lua:

function App:ShouldSwitchLevel()

if self.mapFile ~= "" then

 

self.world = World:Create()

 

Map:Load(self.map)

 

self.mapFile = ""

end

end

 

It just gives me the error: failed to read file ''C:\users\********\documents\leadwerks\projects\buildandshoot''

 

It did get rid of the Debug Assertion Failed! error

Link to comment
Share on other sites

Look at my telport tutorial to see how you can do triggers.

 

I know, and that is the one I am using, but it says ''failed to read file ''[system path to project folder]''. I still did not manage to get rid of that as well :/

Link to comment
Share on other sites

I think your problem is a map file Path, or the way you coded the trigger.

I'm going to report the change map to the wood box collision trigger and tell you, but it should work as it works with keys.

 

Ok found a strange thing on Loadlevel.lua script tab :

Your map parameter is a path :

Script.Map = ""		--path

Perhaps using a simple string would work better, i don't know if LE3 keeps a map relative to actual project or not, but

loadMap works with a simple String nor a Path object.

 

Here is reference you can see a simple String for map path :

 

Map::Load

 

This function loads a Leadwerks map (*.map) file.

Syntax

 

static bool Load(const std::string& path, int flags=LoadScripts)

Stop toying and make games

Link to comment
Share on other sites

Ok i have a VERY SIMPLE solution i tested.

Coding Flowgraph is cool , but well sometimes i just follow one rule : KEEP IT SIMPLE

 

Here is your solution code for your wood collision trigger :

 

LoadLevel.lua :

 

Script.map = "" --path

function Script:UpdatePhysics()


end

function Script:Collision(entity, position, normal, speed)
--"Maps/lol.map"
App:changeMap(self.map)

end

 

 

And now in App.lua remove all your change map code on Loop() function.

Than just add this little function in App.lua :

 

function App:changeMap(name)


self.world = World:Create()

Map:Load(name)

end

 

As you see you don't need to check each loop for map chaging, this is just a function to call.

This is an event happening on collision called by the Wood box collision.

Also you don't need the trigger collision code as here it doesen't matter to detect if you enter collision or not, you just load new map when a collision occurs, that's all smile.png

Stop toying and make games

Link to comment
Share on other sites

Read this as recommended by the creator of this engine. I didn't do the extra work for ****s and giggles smile.png

 

http://www.leadwerks.com/werkspace/files/file/430-next-level/

 

Not releasing the world, 100% causes the memory to go up. Be sure you aren't looking at the Leadwerks.exe and you are looking at your games name exe in Task Manager. The memory keeps going up and up if you don't release the world!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...