Chaosforge Forum

DoomRL => Modding => Topic started by: Uranium on October 16, 2017, 13:15

Title: Help w/ level generation crashes
Post by: Uranium on October 16, 2017, 13:15
so, i've started to put together a module for the first time (the first version of which i *hope* to have released by halloween but ehhhh), but i'm running into issues with randomly generating levels. the first map is an entrance map, upon exiting via the stairs, the game freezes. My module.onGenerate() is simply
Code: [Select]
function hospital.OnGenerate()
generator.reset()
generator.generate_tiled()
end
which is exactly the same as in the doomrl source, and as far as i can ascertain, should produce no errors whatsoever. I suppose it's correct in that it doesn't actually produce an error, it just freezes the game. Any help appreciated.
cheers!
Title: Re: Help w/ level generation crashes
Post by: scotherns on October 17, 2017, 02:04
I don't actually have the source, but would guess that generator.generate_tiled() is causing your hospital.OnGenerate() to be called again, giving you an infinite loop.


Title: Re: Help w/ level generation crashes
Post by: Uranium on October 17, 2017, 02:43
I don't actually have the source, but would guess that generator.generate_tiled() is causing your hospital.OnGenerate() to be called again, giving you an infinite loop.

This makes sense - i had this suspicion as I couldn't find raw code for generator.generate_tiled(). If i replace it with generator.generate_caves_dungeon() (which I can find the code for) I expected it to work, as generate_caves_dungeon() doesn't have any reference to an OnGenerate() hook and seems completely self contained, but it still seems to jam the game in an infinite loop.
I hope I'm not missing something horrendously obvious...
Title: Re: Help w/ level generation crashes
Post by: Tavana on October 17, 2017, 04:00
Try this:

Code: [Select]
function hospital.OnGenerate()
generator.reset()
generator.run( generators.gen_tiled )
end
Title: Re: Help w/ level generation crashes
Post by: Uranium on October 17, 2017, 07:10
Ah, thanks very much Tavana! Works great!
Title: Re: Help w/ level generation crashes
Post by: Tavana on October 17, 2017, 22:19
Glad that helped! :)